All,
Im getting a 400 redirect_url_mismatch error upon attempting to authenticate through google. I'm using python-socal-auth through a django application to achieve this process.
Everything works smoothly, until I get to the final stages of the process where I hit a redirect_uri_mismatch issue.
On google, I receive this message.
"The redirect URI in the request: http://localhost:8000/something/complete/google-oauth2/ did not match a registered redirect URI"
`Request Details
from_login=1
scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
response_type=code
redirect_uri=http://localhost:8000/something/complete/google-oauth2/
state=qT1RLLMa72F8NxFFubHwCVe3GgLDNcgZ
as=-55f896f3314b21af
pli=1
client_id=160177117398
authuser=0
hl=en`
Included below is a screenshot of the client ID's redirect URI.
What am I doing wrong?
Thanks!
This is an error that comes up in the final step of adding the Client ID and Secret to SSA. This happens when the URL to your site is not typed in exactly right in the API console to the newly created Client ID and Secret. This is not your fault, Google is quite picky with the URL.
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.
A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.
Make sure you added the social-auth in the urls.py as
url('', include('social.apps.django_app.urls', namespace='social')),
and on console.developers.google.com set the Authorized redirect URIs
to http://localhost:8000/something/complete/google-oauth2/
One thing to note here is that redirect url should be exactly same till the last trailing slash. In my case, it was like http://localhot:8000/something/complete/google-oauth2
This should have been
http://localhot:8000/something/complete/google-oauth2/
This resulted in redirect_uri_mismatch.
Also define http: and https: in the console for redirect url because redirect url generated by social auth still sends http regardless of ssl setting in your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With