8

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.

enter image description here

What am I doing wrong?

Thanks!

user2714604
  • 193
  • 1
  • 2
  • 5

2 Answers2

4

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.

Imju
  • 539
  • 5
  • 11
3

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/

vmenezes
  • 1,076
  • 2
  • 12
  • 21