Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django allauth google OAuth redirect_uri_mismatch error

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 ?

like image 517
Prasanna Avatar asked Feb 20 '19 11:02

Prasanna


2 Answers

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

ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'

like image 197
Prasanna Avatar answered Nov 19 '22 09:11

Prasanna


**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

like image 40
Vishal Kumar Avatar answered Nov 19 '22 11:11

Vishal Kumar