[Python] My django app broke after windows reinstallation

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    Yesterday I reinstalled Windows and now my Django project’s Google login (using django-allauth v0.65.11) stopped working.

    I use a virtual environment and reinstalled the same dependencies (pip freeze matches exactly). Before the Windows reinstall, everything worked fine.
    Now, when I try to log in with Google, I get this error on the website:

    Third-Party Login Failure
    An error occurred while attempting to login via your third-party account.


    The server console only shows this:

    [28/Aug/2025 14:57:57] "GET /accounts/google/login/callback/?state=h7XieABcvxcuZgpX&code=4%2F0AVMBsJjAduD5uQ3tC334RqFwdAan0rK229B-qJzKmTizkmO68aNYOHyq26FIaYf_WwVYDA&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=1&prompt=consent HTTP/1.1" 200 1152


    No errors, no traceback, nothing.
    Even my custom adapter methods:


    class MySocialAccountAdapter(DefaultSocialAccountAdapter):
    def pre_social_login(self, request, sociallogin):
    print(">>> pre_social_login <<<")
    def populate_user(self, request, sociallogin, data):
    print(">>> populate_user <<<")


    are never called.

    What I’ve tried:


    • Confirmed Google OAuth credentials in Google Cloud Console


    • Checked that SOCIALACCOUNT_ADAPTER path in settings.py is correct


    • Deleted and re-migrated the database


    • Created a fresh Django project and copied code — issue persists


    • Reinstalled Python (3.12) and all dependencies

    Settings (short):

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'tailwind',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',
    'theme',
    'django_browser_reload',
    'django_ckeditor_5',
    ]

    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',
    "django_browser_reload.middleware.BrowserReloadMiddleware",
    'allauth.account.middleware.AccountMiddleware',
    ]

    AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
    ]

    SOCIALACCOUNT_ADAPTER = "core.adapters.MySocialAccountAdapter"



    SOCIALACCOUNT_PROVIDERS = {
    'google': {
    'SCOPE': [
    'profile',
    'email',
    ],
    'AUTH_PARAMS': {
    'access_type': 'online',
    },
    }
    }

    ACCOUNT_EMAIL_VERIFICATION = 'none'

    LOGIN_URL = '/accounts/login/'
    LOGIN_REDIRECT_URL = '/'
    LOGOUT_REDIRECT_URL = '/accounts/login/'

    SOCIALACCOUNT_ONLY = True

    SOCIALACCOUNT_LOGIN_ON_GET=True


    I've tried to enable logging:

    LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {"console": {"class": "logging.StreamHandler"}},
    "loggers": {"allauth": {"handlers": ["console"], "level": "DEBUG"}},
    }


    nothing showed up.

    Continue reading...

Compartilhe esta Página