I could not find a reference as to when I should refresh an OAuth 2 access token outside of the expiration hint. As far as I can tell the v3 APIs return a 401 with an invalid_token error which is what I would expect based on RFC-6750 [1]. However, the same "error" is returned when the client ID is incorrect or the token is malformed. The only difference that I can see is in the "error_description" field.
Should my application be refreshing the access token when it receives a 401 with a JSON response body where "error=invalid_token" and "error_description" contains the word expired?
When I make a request with an expired access token, I receive a 401 response with the following body::
{"error": "invalid_token", "error_description": "access token is expired"}
If I make the same request with a malformed token, I receive a 401 response with the following body:
{"error": "invalid_token", "error_description": "access token is invalid"}
If I make the same request with a garbage value in the "x-api-key" header, I receive a 401 response with the following body:
{"error": "Invalid API key"}
I want to avoid making access token refresh attempts where they cannot possibly succeed. I believe that looking at the error description is the only way to do this today. Is this documented anywhere?
Dave Shawley
AWeber Integrations Technical Lead
Pronouns: he, his, him | Communication Pref: written, async