I am using google oAuth for my python application in which I have feature to automatically logging in by google into my app. When I try to login first time, it will be successfull, but from next time if I will login it doesn't success and each time I gets 500 internal server error.
When I checked error logs, I got following error message on 'credentials = oAuthFlow.step2_exchange(code)' line
Failed to retrieve access token: {
"error" : "invalid_grant"
}
I have valid clientId registered on google. Can anybody tell me why is it happening. I am using python 2.7.
RFC 6749 OAuth 2.0 defined invalid_grant as: The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
THE "INVALID GRANT" ERROR MAY BE RETURNED FOR THE FOLLOWING REASONS 1 The user has revoked your access. 2 The refresh token has not been used for six months 3 The user changed passwords and the refresh token contains Gmail scopes 4 The user has exceeded the maximum number of granted (live) refresh tokens
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
invalid_grant The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client. Right — so for literally any reason possible, our tokens are getting rejected by Google.
It could be caused by any number of things, including ...
I get it a lot when I use the same user for both testing and live use since the two refresh tokens tend to overwrite each other.
The good news is that whatever the cause, the solution is always the same. You need to force a re-authorization from your user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With