I read the comment “// Sometimes we won’t get a refresh token after upgrading a code.” in the sample DrEdit code https://code.google.com/p/google-drive-sdk-samples/source/browse/java/src/com/google/drive/samples/dredit/CredentialMediator.java line 292.
What does “sometimes” mean? Is there a document that describes the circumstances under which I will and won’t be blessed with a refresh token?
Refresh tokens are supplied under two conditions:
In other words, the first time the user authorizes your app and you have offline=true set, you’ll get a refresh token. Subsequent authorizations will for that user will be automatically approved unless the user revokes access. Refresh tokens will not be issued in this case.
If you need to force a refresh token to be issued, add approval_prompt=force to the request.