Django allauth google OAuth redirect_uri_mismatch error

允我心安 提交于 2020-12-30 02:13:47

问题


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 ?


回答1:


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

ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'




回答2:


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

See image by opening link



来源:https://stackoverflow.com/questions/54784981/django-allauth-google-oauth-redirect-uri-mismatch-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!