Created
August 6, 2018 12:42
-
-
Save ibrahimsn98/a989ce1ae03544abeebc7c28b9b57b4e to your computer and use it in GitHub Desktop.
django-rest-framework-jwt-get-user-from-token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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