Google OAuth 2 redirect_uri_mismatch - OmniAuth Rails app

Azzurrio picture Azzurrio · Mar 19, 2014 · Viewed 7.5k times · Source

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:

enter image description here

so what's main the problem here?

Answer

Luan D picture Luan D · May 30, 2014

try this way :

add require "omniauth-google-oauth2" to devise.rb in config/initializers folder

add http://localhost:3000/users/auth/google_oauth2/callback into Redirect URL in google API console https://console.developers.google.com

restart server