social-app-django icon indicating copy to clipboard operation
social-app-django copied to clipboard

You have multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user.

Open xelawafs opened this issue 6 years ago • 9 comments

I get this error when trying to activate a new user from verification code:

You have multiple authentication backends configured and therefore must provide the backendargument or set thebackend attribute on the user.

I've updated my activate function to specify the default authentication channel but still no luck:

def activate(request, uidb64, token, backend='django.contrib.auth.backends.ModelBackend'):

xelawafs avatar Aug 18 '18 16:08 xelawafs

Have the same issue. I've it solved by specifying auth backend directly like this: login(strategy.request, user, backend='social_core.backends.google.GoogleOAuth2') But it's not a clear solution, because it works only for GoogleOAuth2 @xelawafs Did you solve it?

amarynets avatar Oct 09 '18 11:10 amarynets

@xelawafs, how's this activation flow implemented? Is it part of a partial-pipeline flow?

omab avatar Nov 20 '18 00:11 omab

setting a backend with user = authenticate(request, username=username, password=raw_password, backend='django.contrib.auth.backends.ModelBackend') throws 'unicode' object has no attribute 'name'.

/Users/Gregor/.local/share/virtualenvs/###/lib/python2.7/site-packages/social_core/backends/base.py in authenticate if 'backend' not in kwargs or kwargs['backend'].name != self.name or \

gregorvolkmann avatar Apr 21 '19 06:04 gregorvolkmann

@gregorvolkmann, backend parameter for login function (django.contrib.auth.login) must be in the form of an import path, while backend parameter for authenticate function (django.contrib.auth.authenticate) must be in the form of what an authentication backend will expect. In the case of social auth backends, it must be the backend instance not the dotted import path.

ModelBackend doesn't require the backend paramater.

omab avatar Apr 21 '19 13:04 omab

@omab, correct! Solved it by dropping authenticate() and taking the user from my form:

if form.is_valid():
    user = form.save()
    login(request, user, backend='django.contrib.auth.backends.ModelBackend')

gregorvolkmann avatar Apr 22 '19 12:04 gregorvolkmann

@omab, correct! Solved it by dropping authenticate() and taking the user from my form:

if form.is_valid():
    user = form.save()
    login(request, user, backend='django.contrib.auth.backends.ModelBackend')

Thxk mate its workking

balamirdemirtas avatar Jan 29 '20 18:01 balamirdemirtas

if form.is_valid(): user = form.save() login(request, user, backend='django.contrib.auth.backends.ModelBackend')

Elbekgithub avatar Feb 19 '20 14:02 Elbekgithub

For me specifying just the backend worked, backend='django.contrib.auth.backends.ModelBackend' which actually is one of the options for login

rahulkp220 avatar Mar 16 '20 08:03 rahulkp220

I am also facing the same issue . Any update ?

pupattan avatar Sep 15 '20 18:09 pupattan