2👍
✅
The method should look like :
def authenticate(self, request, username=None, password=None):
You can can check the parameters needed for the signature of the method authenticate
by looking at the source of authentication system. The first positioned parameter is request
, and then the credentials are unpacked as named parameters:
def authenticate(request=None, **credentials):
"""
If the given credentials are valid, return a User object.
"""
for backend, backend_path in _get_backends(return_tuples=True):
try:
inspect.getcallargs(backend.authenticate, request, **credentials)
except TypeError:
# This backend doesn't accept these credentials as arguments. Try the next one.
continue
try:
user = backend.authenticate(request, **credentials)
[...]
(_get_backends
represents the list of all backends in settings.AUTHENTICATION_BACKENDS)
Doc about custom authentication :
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#writing-an-authentication-backend
Source:stackexchange.com