Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authenticating with omniauth-google-oauth2 redirect_uri_mismatch

Well I am sorry to publish such a lame question but I have managed to use omniauth with facebook, twitter and even linkedin, but I am still unable to do it with google omniauth 2.0, I found that the issue is related to the callback URI (I must add that I am testing with a local enviroment [localhost]), so I have tried to change the URI in the following ways

http:127.0.0.1:3000/auth/google_oauth2/callback/
http:127.0.0.1:3000/auth/google_oauth2/callback
https:127.0.0.1:3000/auth/google_oauth2/callback/
https:127.0.0.1:3000/auth/google_oauth2/callback
http:localhost:3000/auth/google_oauth2/callback/
http:localhost:3000/auth/google_oauth2/callback *
https:localhost:3000/auth/google_oauth2/callback/
https:localhost:3000/auth/google_oauth2/callback

so far I have tried with each one individually and none of these worked, it looks like the one marked with a * is the one being returned on my browser, but still receiving

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

I am therefor looking for an answer on how to perform this authentication or how to set the callback URI properly for a localhost callback. thanks in advance.

BTW: I am using Rails 4 and omniauth, omniauth-google-oauth2 gems BTW2: I have removed the "//" so these won't be treated like links

  • Additional and related question is, how do I add multiple URIs on the redirect list? I have tried to add them separated by "," or simply with a blank space, as none have worked, then I don't really know what would be the propper way.
like image 216
Wiston Coronell Avatar asked Mar 21 '14 15:03

Wiston Coronell


2 Answers

make sure you make the access type online

config.omniauth :google_oauth2, "[my key]", "[secret]", {access_type: 'online'}
like image 56
anyavacy Avatar answered Oct 05 '22 13:10

anyavacy


I guess you should use

http://localhost:3000/users/auth/google_oauth2/callback

(you missed users in the middle)

like image 37
Sergey Avatar answered Oct 05 '22 11:10

Sergey