I am beginner in drf (Django rest framework), and now I'm making authorization logic with JWT. I heard that djangorestframework-simplejwt is most famous library in drf.
I saw docs, but there are no way to verify token. (exactly i cannot find it :( )
thank you.
CodePudding user response:
in JWT you can verify if a token is valid by decoding it, your key = any key used during token creation, your algorithm = algorithm used during token creation, token = value of the token to decode
import jwt
decoded_result = jwt.decode(<token>, key=<your key>, algorithms=<your algorithm>)
print(decoded_result)
this prints decoded payload from your token if valid, else raises jwt exceptions which can be caught in a try-catch block for further processing.