This good tutorial is a very good introduction to authenticating an Android account and using it using the Android AccountManager .
However, I need to create a client application for the OAuth2 API using the Bearer token for authentication. When I receive a token, I get a timestamp for its expiration, but I do not understand where to store it and how to use it correctly. The problem is that if I do not want to have unnecessary trips to the server, the application will understand that the media became invalid only after it received an HTTP 401 error from the server when requesting any random resource. So what is the best practice to solve this problem:
- Should every network request in my code have a retry mechanism in case the carrier token has become invalid? I probably
invalidateAuthToken if you catch an exception and try again. - Can the sync adapter help here somehow?
Since I am new to Android development, I expect the solution to also be something completely different than I expect.
If relevant, I intend to use Volley to communicate with the server.
nekojsi
source share