Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wilfredinni opened this issue Oct 23, 2024 · 0 comments

Comments

@wilfredinni
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant