Skip to content

Instantly share code, notes, and snippets.

@ibrahimsn98
Created August 6, 2018 12:42
Show Gist options
  • Save ibrahimsn98/a989ce1ae03544abeebc7c28b9b57b4e to your computer and use it in GitHub Desktop.
Save ibrahimsn98/a989ce1ae03544abeebc7c28b9b57b4e to your computer and use it in GitHub Desktop.
django-rest-framework-jwt-get-user-from-token
jwt_decode_handler = api_settings.JWT_DECODE_HANDLER
jwt_get_username_from_payload = api_settings.JWT_PAYLOAD_GET_USERNAME_HANDLER
token = ''
try:
payload = jwt_decode_handler(token)
except jwt.ExpiredSignature:
return
except jwt.DecodeError:
return
username = jwt_get_username_from_payload(payload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment