For me with Django (2.0.1), djangorestframework (3.7.7), djangorestframework-jwt (1.11.0).
I had to do the following to return the user from the token:
token = request.META.get('HTTP_AUTHORIZATION', " ").split(' ')[1] print(token) data = {'token': token} try: valid_data = VerifyJSONWebTokenSerializer().validate(data) user = valid_data['user'] request.user = user except ValidationError as v: print("validation error", v)
Or you can write middleware that will install the user based on their token.
You can read the walkthrough here: http://blog.sadafnoor.me/blog/a-django-rest-framework-jwt-middleware-to-support-request-user/
source share