How to log out using rest framework jwt.
How can I close the existing token for the logged-in user?
Just as there is a get_jwt_token
function, is there a function to break or close?
How to log out using rest framework jwt.
How can I close the existing token for the logged-in user?
Just as there is a get_jwt_token
function, is there a function to break or close?
The best way I found to do this was create a jwt_secret
field in the User model, along with a property to get it, and use uuid
to set the value. Then set the JWT_GET_USER_SECRET_KEY
in settings.py
to that property. When you want to logout, you reset that jwt_secret
which in turn makes all tokens generated with the old jwt_secret
invalid. I read about it and got started with it from this blog post https://tag1consulting.com/blog/building-api-django-20-part-i