Django Allauth Google OAuth: MultipleObjectsReturned even though no duplicates in MySQL

I’m using Django + MySQL with django-allauth and Google OAuth.

Login fails with this error:

MultipleObjectsReturned: get() returned more than one SocialAccount

The confusing part is that the database does not contain duplicates.

Here is what I checked:

1. No duplicate Google accounts

SQL:

SELECT uid, COUNT(*)

FROM socialaccount_socialaccount

GROUP BY uid

HAVING COUNT(*) > 1;

→ returns 0 rows.

2. No duplicate users by email

Python:

User.objects.values("email")

.annotate(count=Count("id"))

.filter(count__gt=1)

→ also empty.

3. My relevant allauth settings:

SITE_ID = 1

ACCOUNT_EMAIL_REQUIRED = True

ACCOUNT_UNIQUE_EMAIL = True

SOCIALACCOUNT_QUERY_EMAIL = True

ACCOUNT_USERNAME_REQUIRED = False

ACCOUNT_AUTHENTICATION_METHOD = "email"

4. Only one Google OAuth app and only using localhost in callback.

Credentials are correct.

5. Even after deleting all rows from auth_user and socialaccount tables, the next login still throws the same error.

6. There is really only one row in socialaccount_socialaccount, but allauth still raises MultipleObjectsReturned during login.

My question:

What else in django-allauth or the authentication pipeline can cause a MultipleObjectsReturned error even when the database does not contain duplicates?

Is there something like:

a temporary duplicate created during login?

signals or adapters running twice?

duplicate queries on email lookup?

a caching issue?

Any debugging tips would help.

Вернуться на верх