Google OAuth 2 authorization - Error redirect uri mismatch

0 votes


On the website https://code.google.com/apis/console I have registered my application, set up a 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 this message mean, and how can I fix it? I use the gem omniauth-google-oauth2.

Feb 16, 2022 in Others by Aditya
• 7,680 points
7,327 views

1 answer to this question.

0 votes
To answer your question, you need to redirect URI where the response is returned and has to be registered in the APIs console, and the error is indicating that you haven't done that, or haven't done it correctly. Go to the console for your project and look under API Access. You should see your client ID & client secret there, along with a list of redirect URIs. If the URI you want isn't listed, click edit settings and add the URI to the list.

Please Note that updating the google api console and that change being present can take some time. Generally only a few minutes but sometimes it seems longer.
answered Feb 16, 2022 by Soham
• 9,730 points
This doesn't solve the problem, when I'm inputting the raw url with the client ID and redirect_uri then it is working fine but not through the code.

Related Questions In Others

0 votes
0 answers