Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get jwt user in django

from rest_framework_simplejwt.backends import TokenBackend
token = request.META.get('HTTP_AUTHORIZATION', " ").split(' ')[1]
data = {'token': token}
   try:
      valid_data = TokenBackend(algorithm='HS256').decode(token,verify=False)
      user = valid_data['user']
      request.user = user
   except ValidationError as v:
      print("validation error", v)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jwt #user #django
ADD COMMENT
Topic
Name
7+7 =