13

I am using Google OAuth for my Django App (via allauth package)

I have followed all standard configuration steps. In Google Developer console here's what i have:

Authorized JavaScript origins

https://example.com 

Authorized redirect URIs

https://example.com/accounts/google/login/callback/ - login fails http://example.com/accounts/google/login/callback/ - login succeeds 

What i observe that if i have a https redirect URL in Authorized redirect URIs, it does not allow login and it fails with redirect_uri_mismatch Error. If i have a http redirect URL then the login succeeds.

What do i need to do to have a https enabled redirect URL ?

3 Answers 3

28
+300

Adding the following in production settings.py fixed the problem for me:

ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. Somehow the same code works for my localhost but fail in production and this was the fix that got me out of it
Gave you a bounty to get you over 1k points. My way of saying thanks. Forgot to add that my social provider was GitHub so your QnA was the same issue with the same fix for me
Where did you find this setting?
This is very useful and very hidden. Where did you find it? Google OAuth wouldnt work without this.
1

**This worked for me :

  1. Go to https://console.developers.google.com
  2. Add without port http://127.0.0.1/accounts/google/login/callback/
  3. Also Add http://localhost/accounts/google/login/callback/
  4. see the image in the link for detail

image

1 Comment

Please also check your, URLS in urls.py
0

In my case, the problem was in the following:

  1. My website switched the access to HTTPS-only connections, while in Google API dashboard was http://profile.example.com/accounts/google/login/callback/.
  2. So, I changed: from http -> https and it begins to work fine. enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.