fmr5ag
Last Updated: July 08, 2017
·
7.884K
· adambird
Adam bird 2015 01 square 400px

Avoid 'Invalid Credentials' with Google OAuth2

I was struggling setting up OAuth2 authorisation to Google and the problem was down to the scope I was requesting.

I requested https://www.googleapis.com/auth/calendar in order to access the Calendar API on behalf of the user but was receiving

"reason": "authError",
"message": "Invalid Credentials"

Turns out you also have to request the https://www.googleapis.com/auth/userinfo.email scope as well as the scopes you're interested in. Google returns the email in the credentials hash and thus, I believe, if you haven't requested access to it you can't read it.

Say Thanks
Respond

3 Responses
Add your response

16137
Profile pic

If you are using https://github.com/zquestz/omniauth-google-oauth2 make sure to follow the note in README.
"You must enable the "Contacts API" and "Google+ API" via the Google API console."

This fixed the 'Could not authenticate you from GoogleOauth2 because "Invalid credentials".' problem for me.

over 1 year ago ·
18068
None

Thanks abhishek77in! You saved me lots of trouble.

over 1 year ago ·
22263
None

Thank you! This solved my problem.

over 1 year ago ·