问题
If my user uses oauth v2 to cloud print to get a credential, how do I get a credential that is good for at least 48 hours?
We need to be able to get access to the printer, and keep it for some days. (Conceivably we could require the user to re auth to google once or twice a week, but certainly not more.)
If google cloud print can't do this, what system can? (Require cross platform printing, from cloud to win, osx and linux, also require ability to do raw printing to local printer, not just print driver printing.)
Thanks!
回答1:
There are two types of "credentials" in OAuth2 process: access token (its lifetime is short and determined by expires_in field of the OAuth2 server response) and refresh token which is virtually permanent unless user revokes granted access. When you possess refresh token you can get valid access token.
Refresh token is returned upon first auth request with parameter access_type=offline. All you need is to store obtained refresh token securely and use it to request for access token when necessary.
Read more in the document https://developers.google.com/accounts/docs/OAuth2WebServer
来源:https://stackoverflow.com/questions/15538143/google-cloud-print-how-long-is-the-token-good-for-to-submit-jobs-to-cloud-prin