I'm using knox LoginView to make the login of my backend. This is the code of the view:
class Login(LoginView):
permission_classes = (AllowAny,)
def post(self, request, format=None):
serializer = AuthTokenSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
login(request, user)
return super(Login, self).post(request, format=None)
When I execute my frontend (developed with angular) and try to login using Microsoft Edge everything works fine. I get the token and save it in local. Same result if I execute a POST using Postman. But, If I try to do the same using Firefox I receive 401 Unauthorized with this JSON:
{"detail":"Invalid token."}
Why does it ask for a token if its an AllowAny view? Why does it work in Edge and Postman but not in Firefox?
More data:
This is the authentication class in settings.py:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'knox.auth.TokenAuthentication',
),
}
EDIT: Actually, it works usign Firefox Developer Edition.
I solved the problem cleaning cookies.