I am working on a java CLI application that manages to retrieve an OAuth token from a OpenId provider. I need to save this token so that when the user runs the CLI again, I can reuse the token if it has not expired; else simply use the refresh token to request a new one.
This is my first time to integrate OAuth in a java CLI application where the OAuth token needs to be persisted. This raises few concerns and I wanted to get few opinions:
Is it safe to store those tokens locally? Specially considering the browser does that every time in cookies or some other session store. I plan on having the token expiry time in days (I understand its not ideal but thats one of the requirement).
If the answer to above is Yes, what would be a safe way to do it? Does it have to be encrypted or plane text is acceptable?
Is storing to something like keychain makes any sense? If yes, is there a way to do it in a platform independent manner?