All google Login Urls unavailable: Reverse for 'google_login' not found.

I hit the bug first here:

Reverse for 'google_login' not found. 'google_login' is not a valid view function or pattern name.

on my home page

After some digging I realized that I do not have any url that is of the pattern ‘accounts/google/…’

I used to have all these urls previously in this same project, They seem to have dissapeared. [Returned to this project after a while]

Do let mw know if you have any insights you could have on how I could solve it.

[part of] My settings.py:

...

ALLOWED_HOSTS = []

SITE_ID  = 1 # for app django.contrib.sites

AUTHENTICATION_BACKENDS = [
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
]


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # added 3rd party apps:
    'django.contrib.sites', # required by allauth
    'allauth',
    'allauth.account', # local account
    'allauth.socialaccount', # social account login
    'allauth.socialaccount.providers.google', 

    # adding created apps:
    'websiteMain.apps.WebsitemainConfig',
]

LOGIN_REDIRECT_URL = "/"

# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
    'google': {
        'APP': {
            'client_id': '<MyID>', 
            'secret': '<MySecret>',
            # 'key': '' 
        },
        'SCOPE': [
            'profile',
            'email',
        ],
        'AUTH_PARAMS': {
            'access_type': 'online', # default
        },
        'OAUTH_PKCE_ENABLED': True,
    }
}

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'asapawa.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',

                # ADDED:
                # `allauth` needs this from django
                'django.template.context_processors.request',
            ],
        },
    },
]

WSGI_APPLICATION = 'asapawa.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}
...

my project’s urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),

    #ALL AUTH:
    path('accounts/', include('allauth.urls')),

    #MAIN APP: [make sure to keep it last]
    path('', include("websiteMain.urls"))
]

Using Django==3.2.19 and django-allauth==0.54.0

Does anyone have any lead I could pursue? I am puzzled…

stumbled upon the same problem, have you figured out something?

Unfortunately not :frowning:

I started a new project, and I had the same issue there too. I also tried downgrading the version… No luck.

FINALLY FOUND THE ERROR!!!

It was due to very bad error handling inside the allauth package, I went inside the allauth package’s urls.py and did some changes to identify the error. Here is the changed venv\Lib\site-packages\allauth\urls.py (all the print statements were added by me):

from importlib import import_module

from django.urls import include, path

from allauth.socialaccount import providers

from . import app_settings


urlpatterns = [path("", include("allauth.account.urls"))]

if app_settings.SOCIALACCOUNT_ENABLED:
    urlpatterns += [path("social/", include("allauth.socialaccount.urls"))]

# Provider urlpatterns, as separate attribute (for reusability).
provider_urlpatterns = []
for provider in providers.registry.get_list():
    try:
        print('----------------------------------------')
        print(provider.id, ":", provider.get_package())
        prov_mod = import_module(provider.get_package() + ".urls")
    except ImportError as e:
        print(e.msg)
        continue
    prov_urlpatterns = getattr(prov_mod, "urlpatterns", None)
    if prov_urlpatterns:
        provider_urlpatterns += prov_urlpatterns
urlpatterns += provider_urlpatterns

Atleast in my case, There was indeed an exception! It was because urllibv2.0 did not support the old open SSL in my machine… Here is my output after using the changed package:

Watching for file changes with StatReloader
Performing system checks...

----------------------------------------
google : allauth.socialaccount.providers.google
urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.1.0h  27 Mar 2018'. See: https://github.com/urllib3/urllib3/issues/2168
System check identified no issues (0 silenced).
August 06, 2023 - 20:29:45

So I downgraded urllib to an older version and it solved the errors in a jiffy! I would suggest you use the modified urls.py and see why the google urls are not being imported for you.