401 Error when using DRF and LDAP using Token Authentication

Viewed 154

I am using Token Authentication and LDAP for login. In my settings.py file, I have set:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticatedOrReadOnly', )
}

But when I try to login, I get 401 Unauthorized error.

enter image description here

What am I doing wrong here?

Thank you

1 Answers

I resolved the error by setting the login class as "class LoginAPI(ObtainAuthToken)" instead of "class LoginAPI(APIview)" in views.py.

Thank you

Related