On the website https://code.google.com/apis/console I have registered my application, set up generated Client ID: and Client Secret to my app and tried to log in with Google. Unfortunately, I got the error message:
Error: redirect_uri_mismatch
The redirect URI in the request: http://127.0.0.1:3000/auth/google_oauth2/callback did not match a registered redirect URI
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
response_type=code
redirect_uri=http://127.0.0.1:3000/auth/google_oauth2/callback
access_type=offline
approval_prompt=force
client_id=generated_id
What does mean this message, and how can I fix it? I use the gem omniauth-google-oauth2.
Rails users (from the omniauth-google-oauth2 docs):
REMEMBER: Do not include the trailing "/"
for me it was because in the 'Authorized redirect URIs' list I've incorrectly put
https://developers.google.com/oauthplayground/
instead ofhttps://developers.google.com/oauthplayground
(without/
at the end).This seems quite strange and annoying that no "one" solution is there. for me http://localhost:8000 did not worked out but http://localhost:8000/ worked out.
When you register your app at https://code.google.com/apis/console and make a Client ID, you get a chance to specify one or more redirect URIs. The value of the
redirect_uri
parameter on your auth URI has to match one of them exactly.Checklist:
http
orhttps
?&
or&
?/
) or open?
(CMD/CTRL)+F
, search for the exact match in the credential page. If not found then search for the missing one.I had the same issue with google sign in, I was about to pull my hairs!!! I had correctly entered my callbacks in google Credential panel at google developer console here was my redirect urls :
https://www.example.com/signin-google
https://www.example.com/signin-google/
https://www.example.com/oauth2callback
https://www.example.com/oauth2callback/
every thing seems fine right? but it still didn't work until I added one more magical Url I added signin-google url (which is default google callback) without www and problem solved.
take it into account (depending of you domain) you may or may not need to add both with and without www urls