At least with Google, the access token eventually expires. That's why the Android AccountManager has an invalidateAuthToken method - the cached access token has expired, and you need to tell the AccountManager to leave you the old one and get a new one instead. This makes caching of the token somewhat safer, as the token itself does not give you perpetual access as that user. Instead, when it is valid, it simply says: "At some point in the recent past, this token was acquired by a trusted source."
Here are a few things I found useful when working with tokens. The first is the Google tokeninfo endpoint. The token itself is just base64 encoded JSON. This means that it is not encrypted, so you must be sure that you use HTTPS for communication. However, this also means that you can check the token and better understand what is happening.
https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=
If your token was "abcdef", you should go to:
https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=abcdef
and Google will unpack your token. This is a simple JSON object that includes the "expires_in" field, which indicates the number of seconds for which the token is still valid. At 6:03 in the video below, you can see the unpacked token:
https://developers.google.com/events/io/sessions/383266187
This video provides a detailed overview of OAuth2 and is worth a full look if you are going to deal with OAuth and tokens. The speaker also discusses other forms of Oauth2 tokens that are not access tokens that do not expire.
Another useful resource is the OAuth Playground. This allows you to do basic things, such as request areas, compose requests, and return tokens. This link seems to work sporadically, and in Chrome I had to install the Oauth Playground app:
https://developers.google.com/oauthplayground/
And here’s a tutorial by Tim Bray, the speaker on the video explaining how to use access tokens to communicate with the server from the Android application. This was useful to me because I began to understand how different things in the Google APIs console work together:
http://android-developers.blogspot.in/2013/01/verifying-back-end-calls-from-android.html
Regarding the actual answer to your question, I would say that you never need to cache the access token on the server. As explained in the “Checking Android Callbacks” section above, token checking is almost always a quick static call, which means there is no reason to cache tokens:
Libraries can cache Google certificates and renew them only when necessary, so verification (almost always) is a quick static call.
Finally, you can use the AccountManager to get access tokens. However, instead, Google recommends using the GoogleAuthUtil class in the Utilities library instead:
In short, what is the difference from using an OAuth2 request getAuthToken and getToken
Here's a comment by Tim Bray, the same guy who reappeared from the above links, stating that they are making efforts on the GoogleAuthUtil route. Please note, however, that this means that you will be limited to Google authentication. I believe that AccountManager can be used to get, for example, a Facebook token, and not in the case of GoogleAuthUtil .