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.
Written by Adam Bird
Related protips
5 Responses

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.

Thanks abhishek77in! You saved me lots of trouble.

Thank you! This solved my problem.

Thanks for sharing.
Thanks for sharing this information...