How to remove JJT Django token?

I am using the JNON API for the Django rest web interface which is here on github ( https://github.com/GetBlimp/django-rest-framework-jwt/tree/master/ ).

I can successfully create tokens and use them to call secure REST APis. However, there are certain cases when I would like to delete a certain token before its expiration date. Therefore, I decided to do this with a view such as:

class Logout(APIView):
    permission_classes = (IsAuthenticated, )
    authentication_classes = (JSONWebTokenAuthentication, )

    def post(self, request):
        # simply delete the token to force a login        
        request.auth.delete()  # This will not work
        return Response(status=status.HTTP_200_OK)

request.authis just a string object. This way, of course, this will not work, but I was not sure how I can clear the underlying token.

EDIT

, , , JWT . . ?

+4
1

, , JWT . , , ATM.

, , , .

+3

Source: https://habr.com/ru/post/1660755/


All Articles