Skip to main content
edited body; edited title
Source Link
awidgery
  • 1.9k
  • 1
  • 23
  • 37

Django RestREST Framework TokenAuthentication to authenticate in Django generally

We're using rest_framework.authentication.TokenAuthentication to authenticate API users in Django RestREST Framework using an access token.

Is there a way to use this same class to authenticate users for Django generally?

I've tried adding it straight in to AUTHENTICATION_BACKENDS but it doesn't work:

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",

    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
    
    'rest_framework.authentication.TokenAuthentication',
)

Is there a quick way to do this or do I need to write a custom authentication backend?

Django Rest Framework TokenAuthentication to authenticate in Django generally

We're using rest_framework.authentication.TokenAuthentication to authenticate API users in Django Rest Framework using an access token.

Is there a way to use this same class to authenticate users for Django generally?

I've tried adding it straight in to AUTHENTICATION_BACKENDS but it doesn't work:

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",

    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
    
    'rest_framework.authentication.TokenAuthentication',
)

Is there a quick way to do this or do I need to write a custom authentication backend?

Django REST Framework TokenAuthentication to authenticate in Django generally

We're using rest_framework.authentication.TokenAuthentication to authenticate API users in Django REST Framework using an access token.

Is there a way to use this same class to authenticate users for Django generally?

I've tried adding it straight in to AUTHENTICATION_BACKENDS but it doesn't work:

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",

    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
    
    'rest_framework.authentication.TokenAuthentication',
)

Is there a quick way to do this or do I need to write a custom authentication backend?

Source Link
awidgery
  • 1.9k
  • 1
  • 23
  • 37

Django Rest Framework TokenAuthentication to authenticate in Django generally

We're using rest_framework.authentication.TokenAuthentication to authenticate API users in Django Rest Framework using an access token.

Is there a way to use this same class to authenticate users for Django generally?

I've tried adding it straight in to AUTHENTICATION_BACKENDS but it doesn't work:

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",

    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",
    
    'rest_framework.authentication.TokenAuthentication',
)

Is there a quick way to do this or do I need to write a custom authentication backend?