Skip to content

knox.auth.TokenAuthenticationd does not work in DEFAULT_AUTHENTICATION_CLASSES #371

@wilfredinni

Description

@wilfredinni

I am having problems setting the default rest framework authentication class to knox.auth.TokenAuthentication. It seems that in the views I have to explicitly set authentication_classes = (TokenAuthentication,):
settings.y

REST_FRAMEWORK = {
    #  This is not having an effect at all.
    "DEFAULT_AUTHENTICATION_CLASSES": ("knox.auth.TokenAuthentication",)
}

views.py

from knox.auth import TokenAuthentication


class UserProfileView(generics.RetrieveUpdateAPIView):
    serializer_class = UserProfileSerializer
    authentication_classes = (TokenAuthentication,)  # It won't work without this line
    permission_classes = (permissions.IsAuthenticated,)

    def get_object(self):
        return self.request.user

And if I comment authentication_classes = (TokenAuthentication,) I get:

{
	"detail": "Authentication credentials were not provided."
}

I may be missing something, but I can't figure it out. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions