AuthAlreadyAssociated at /complete/*/ This * account is already in use

Today, 25th June 2022, Ukraine is still bravely fighting for democratic values, human rights and peace in whole world. Russians ruthlessly kill all civilians in Ukraine including childs and destroy their cities. We are uniting against Putin’s invasion and violence, in support of the people in Ukraine. You can help by donating to Ukrainian's army.

If an already logged-in user will try to start a social auth workflow you will notice this error.

One of the approaches how to overcome this and perform login event if auth already associated is overwriting do_complete function.

The disadvantage of this method that we will import some staff from python-social-auth internals, so our code may be broken after the new version release.

This one tested on python-social-auth==0.3.6 and social-app-django==2.0.0

Define view:

from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt
from social_core.actions import do_complete
from social_django.utils import psa
from social_django.views import NAMESPACE, _do_login
from django.contrib.auth import REDIRECT_FIELD_NAME

def complete(request, backend, *args, **kwargs):
    """Authentication complete view"""
    return do_complete(request.backend, _do_login, user=None,
                       redirect_name=REDIRECT_FIELD_NAME, request=request,
                       *args, **kwargs)

Add to main

from social_django.urls import extra

   url(r'^complete/(?P<backend>[^/]+){0}$'.format(extra), complete, name='complete'),


How was this done? Just find site-packages\social_django\ and see how '^complete/... url defined. Follow complete view and copy it to your code, then just replace request.user it to None

#django #python-social-auth
Ivan Borshchov profile picture
Nov 05, 2017
by Ivan Borshchov
Did it help you?
Yes !

Best related