Django Allauth Google Sign-In не работает
Я пытаюсь заставить пользовательскую форму работать с Google через пакет django-allauth[socialaccount]
, но при нажатии на кнопку Google Sign-In я получаю строку запроса ?process=login
, добавленную к URL, но ничего больше.
Я следовал примерам, доступным в официальном репо и, в частности, этому частичному шаблону, который я частично скопировал в свой собственный шаблон:
{% load i18n %}
{% load allauth %}
{% load socialaccount %}
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
{% if not SOCIALACCOUNT_ONLY %}
{% element hr %}
{% endelement %}
{% element h2 %}
{% translate "Or use a third-party" %}
{% endelement %}
{% endif %}
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
{% include "socialaccount/snippets/login_extra.html" %}
{% endif %}
Мой шаблон:
{% extends "base.html" %}
{% load allauth socialaccount %}
{% load i18n %}
{% block body_class %}bg-white rounded-lg py-5{% endblock %}
{% block content %}
<div class="flex justify-center items-center min-h-screen">
<div class="card w-96 bg-base-100 shadow-xl">
<div class="card-body">
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
{% include "socialaccount/snippets/login_extra.html" %}
{% endif %}
</div>
</div>
</div>
{% endblock content %}
views.py
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .forms import CustomSignupForm
def index(request):
if request.method == "POST":
form = CustomSignupForm(request.POST)
if form.is_valid():
return HttpResponseRedirect("/thanks/")
else:
form = CustomSignupForm()
return render(request, "entrance.html", {"form": form})
auth_app/urls.py
from django.urls import path
from . import views
urlpatterns = [
path("login", views.index, name="account_login"),
path("register", views.index, name="account_signup"),
path("login", views.index, name="google_login"),
]
root urls.py:
from django.contrib import admin
from django.urls import include, path
from django.views.generic.base import RedirectView
from django.conf import settings
from django.views import defaults as default_views
urlpatterns = [
path("", RedirectView.as_view(url="register", permanent=False)),
path("", include("auth_app.urls")),
path("admin/", admin.site.urls),
path("__debug__/", include("debug_toolbar.urls")),
]
settings.py:
...
SOCIALACCOUNT_PROVIDERS = {
"google": {
"EMAIL_AUTHENTICATION": True,
"SCOPE": [
"profile",
"email",
],
"APP": {
"client_id": "xxx",
"secret": "xxx",
},
"AUTH_PARAMS": {
"access_type": "online",
},
"FETCH_USERINFO": True,
"OAUTH_PKCE_ENABLED": True,
}
}
...
Я подумал, что проблема может возникнуть из-за того, что я изменил URL по умолчанию с domain.com/accounts/login
на domain.com/login
, изменил корневой urls.py, но и там никаких изменений не произошло.
Я не знаю, где искать дальше. Любая идея будет приветствоваться.