Trying to get OAuth2 Google login working, this is the raw request that my app makes:
Method: POST
URL: https://www.googleapis.com/oauth2/v3/token
Headers: Content-Type: application/x-www-form-urlencoded
Values:
client_id
: XXX-0123456789abcdef0123456789abcdef.apps.googleusercontent.com
client_secret
: A1b2C3d4E5f6G7h8I9j0K1l2M
code
: 1/A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S9t0U1v
grant_type
: authorization_code
redirect_uri
: http://localhost:5000/callback/google/
And this is the response:
Status: 401 Unauthorized
Body:
{
"error": "invalid_client",
"error_description": "Unauthorized"
}
Have verified that this is the exact request / response that my app is making (a Python app using Flask and rauth), and have verified that I can reproduce the exact same request / response using Postman.
Per instructions in other threads, I have done all of the following in the Google APIs console:
- In "OAuth consent screen" settings, set "Product name" to something different than "Project name"
- Also in "OAuth consent screen" settings, double-check that email is set
- Enable the Google+ API
- Enable the Gmail API
- Recreate the client ID / secret
- Double-check that there are no leading or trailing spaces in the client ID / secret values, I have copied them correctly from the API console
No matter what I do, still getting the same response of "invalid_client": "Unauthorized"
.
Help with this would be appreciated. Am trying to set up OAuth2-powered "Log in with X" functionality in my app, have gotten Facebook and Twitter working without issues, would like to get Google working too, but if I can't resolve this then I'm afraid I'll have to ditch Google auth.