I've a problem with authenticating Google account with my Rails app. I'm using omniauth-google-oauth2 gem with Devise. Always get this Error when I try to access google account:
Error: redirect_uri_mismatch
The redirect URI in the request: http://localhost:3000/users/auth/google_oauth2/callback did not match a registered redirect URI
I'm sure that the registered redirect URI in my google console app is right and identical with requested one, just like that:
so what's main the problem here?
Make sure you set up the Product Name and Email address via the Consent Screen Link.
Per the omniauth-google-oauth2 documentation you need to:
Go to 'https://console.developers.google.com' Select your project. Click 'APIs & auth' Make sure "Contacts API" and "Google+ API" are on. Go to Consent Screen, and provide a 'PRODUCT NAME' Wait 10 minutes for changes to take effect.
I had the same issue, made the updates, waited 10 minutes, still nothing, went to lunch, then it started to work. Guess patience was part of the key to success on this one.
Mine solution is to force redirect_url in both (code/token) stages, devise.rb initializer:
there is discussion about the issue here: https://github.com/zquestz/omniauth-google-oauth2/issues/181
try this way :
add http://localhost:3000/users/auth/google_oauth2/callback
into Redirect URL in google API console https://console.developers.google.comrestart server
Be careful of what client id you are setting.
Google API provides two:
Client ID for Google Compute and App Engine
Client ID for web applications
You need to use Client ID for web applications