Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "Error: redirect_uri_mismatch" with google_oauth2

The URL's seem right (Last updated them yesterday):

enter image description here

The files too:

omniauth.rb:

provider :google_oauth2, 'MY_CLIENT_ID.apps.googleusercontent.com', 'MY_CLIENT_SECRET',
           :scope => 'https://mail.google.com/mail/feed/atom/'

Error: redirect_uri_mismatch
The redirect URI in the request: http://localhost:3000/auth/google_oauth2/callback did not match a registered redirect URI

header.html.erb

<li><%= link_to "Sign in with Google", "auth/google_oauth2" %></li>

routes.rb:

match '/auth/:provider/callback', to: 'sessions#omniauth_create'

But I'm getting this:

> Error: redirect_uri_mismatch The redirect URI in the request:
> http://localhost:3000/auth/google_oauth2/callback did not match a
> registered redirect URI

(Twitter and Facebook OmniAuth are working perfectly)

Not sure what is the problem. Any usggestions to fix this?

EDIT

I changed the URI to http...:

enter image description here

But still getting the same error.

like image 488
alexchenco Avatar asked Nov 02 '12 23:11

alexchenco


People also ask

What does error 400 Redirect_uri_mismatch mean?

This error typically means the Client Redirect URL was not properly added to the OAuth Web Application in the Google Cloud Console. To resolve this, the user will need to copy the Client Redirect URL from the Single Sign-On Settings page from ThinkCentral, my.hrw.com, or HMH Ed.

How do I fix OAuth error?

When a user tries to login after the session id is expired, the system throws the OAuth error. Solution: Typically, clearing the browser or device cache fixes the problem.


1 Answers

It looks like the request is hitting http://localhost:3000/auth/google_oauth2/callback, but your specified redirect URI matching the similar pattern is for https. Adding http://localhost:3000/auth/google_oauth2/callback to your list of redirects may potentially solve that issue.

EDIT: Another potential fix is including a trailing / in the corresponding redirect URIs, which appeared to work in this case.

like image 90
RocketDonkey Avatar answered Oct 19 '22 12:10

RocketDonkey