1👍
✅
django provides an AUTHENTICATION_BACKENDS
setting which should do what you require.
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
Ours looks like this ….
AUTHENTICATION_BACKENDS = (
'social_auth.backends.facebook.FacebookBackend', # fb backend par social_auth
'social_auth.backends.twitter.TwitterBackend', # twitter backend par social_auth
'backends.EmailAuthBackend',
'backends.APIAuthBackend',
'django.contrib.auth.backends.ModelBackend',
)
In out case, the backends.APIAuthBackend
is where we check the supplied user auth token. You simply need to write your authentication code in the def authenticate
method of that class which returns a user if the token exists.
The django docs provides more info.
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#writing-an-authentication-backend
👤io2
Source:stackexchange.com