Reputation: 1181
I know this question asked many times but currently we have a problem with fetching access token from Google Oauth. Actually, "sign in with Google" works for some accounts on the other hand it doesn't work for some accounts. So we couldn't catch the exact problem.
Actually, there is no problem with fetching code from googleapis...auth?... -> return code.
But fetching access token returns error:
https://oauth2.googleapis.com/token?code=4/0AY0...
&client_id=....apps.googleusercontent.com
&client_secret=...
&redirect_uri=...
&grant_type=authorization_code
Some cases we encounter with:
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
Any suggestion?
Note: I did some research, but none of the suggestions helped (spelling, checking server time, adding access_type=offline to the first OAuth step url, etc.)
Solution:
When I try to fetch token with same code multiple time, google throws invalid_grant
error.
1. call https://oauth2.googleapis.com/token?code=my_code -> returns OK.
2. call same request again https://oauth2.googleapis.com/token?code=my_code -> returns invalid_grant.
Upvotes: 1
Views: 885
Reputation: 1181
When you try to fetch token with same code multiple time, google throws invalid_grant error.
1. call https://oauth2.googleapis.com/token?code=my_code -> returns OK.
2. call same request again https://oauth2.googleapis.com/token?code=my_code -> returns invalid_grant.
Upvotes: 1