Urjit
Urjit

Reputation: 395

Google token refresh returns "Token has been expired or revoked."

I have a Google OAuth2 client approved by Google, which provides offline access to user's account with required scopes. My backend application stores and uses the refresh token to refresh the access tokens as and when needed.

Lately, we are seeing that our token refresh attempt is met with an error from Google with:

{
    "error" : "invalid_grant",
    "error_description" : "Token has been expired or revoked."
}

There is no additional information.

Nothing has changed in my Google OAuth client. The user has not changed account password. The user has not revoked access to my client.

What could be the reason for suddenly getting such errors for token refresh? And how do I avoid this in future (if possible)?

Upvotes: 14

Views: 11320

Answers (2)

Bob Boroujerdi Far
Bob Boroujerdi Far

Reputation: 39

I had same issue, because I run my code in 2 different files and what I did remove token.pickle file, re-run it again.

Upvotes: 1

pinoyyid
pinoyyid

Reputation: 22286

Are you inadvertently asking for the refresh token multiple times? There is a limit of approx. 25 refresh tokens that an account can have extant.

Upvotes: 3

Related Questions