4

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?

marcelo.delta
  • 2,730
  • 5
  • 36
  • 71
  • 3
    Possible duplicate of [How to delete a django JWT token?](https://stackoverflow.com/questions/40604877/how-to-delete-a-django-jwt-token) – Brown Bear Aug 29 '17 at 11:32

1 Answers1

3

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

Bill R
  • 31
  • 2