使用 Google 在确认页面上重定向登录以继续 Django
Login with Google redairecting on conformation page to continue Django
我正在尝试将 Google 身份验证集成到我的登录页面中。我在 Django 工作。我在我的登录页面上添加了 Google 按钮登录,但是当我单击该按钮时,我将重定向到 accounts/google/login ,它要求确认继续以及带有登录和注销的菜单.
但我想要的是当我点击按钮时它应该要求帐户登录。
这是我的登录屏幕:
这是我点击按钮得到的结果:
这是我在 HTML 中的按钮登录代码:
Login.html:
{% if user.is_authenticated %}
<p>Welcome, You are logged in as {{ user.username }}</p>
{% else %}
<a href="{% provider_login_url 'google' %}">Login With Google</a>
{% endif %}
如何跳过这个确认页面,如果有人能帮助我,我会很高兴谢谢。
我已经使用以下命令卸载了 Django-allauth:
pip uninstall django-allauth
之后我安装了一个旧版本:
pip install django-allauth==0.45
然后:
python manage.py makemigrations
pytthon manage.py migrate
完成。
此行为发布于 version 0.47.0:
Added a new setting SOCIALACCOUNT_LOGIN_ON_GET that controls whether or not the endpoints for initiating a social login (for example, “/accounts/google/login/”) require a POST request to initiate the handshake. As requiring a POST is more secure, the default of this new setting is False.
您可以在 settings.py 文件中添加标志以避免中间页面:
SOCIALACCOUNT_LOGIN_ON_GET=True
并继续使用最新版本的库。
我正在尝试将 Google 身份验证集成到我的登录页面中。我在 Django 工作。我在我的登录页面上添加了 Google 按钮登录,但是当我单击该按钮时,我将重定向到 accounts/google/login ,它要求确认继续以及带有登录和注销的菜单.
但我想要的是当我点击按钮时它应该要求帐户登录。
这是我的登录屏幕:
这是我点击按钮得到的结果:
这是我在 HTML 中的按钮登录代码: Login.html:
{% if user.is_authenticated %}
<p>Welcome, You are logged in as {{ user.username }}</p>
{% else %}
<a href="{% provider_login_url 'google' %}">Login With Google</a>
{% endif %}
如何跳过这个确认页面,如果有人能帮助我,我会很高兴谢谢。
我已经使用以下命令卸载了 Django-allauth:
pip uninstall django-allauth
之后我安装了一个旧版本:
pip install django-allauth==0.45
然后:
python manage.py makemigrations
pytthon manage.py migrate
完成。
此行为发布于 version 0.47.0:
Added a new setting SOCIALACCOUNT_LOGIN_ON_GET that controls whether or not the endpoints for initiating a social login (for example, “/accounts/google/login/”) require a POST request to initiate the handshake. As requiring a POST is more secure, the default of this new setting is False.
您可以在 settings.py 文件中添加标志以避免中间页面:
SOCIALACCOUNT_LOGIN_ON_GET=True
并继续使用最新版本的库。