2
I am studying Python and needed to solve an exercise using JWT (JSON Web Tokens).
It was necessary to create a token and verify the validity, searching for example codes, found in the documentation itself some options that easily met the need.
In the examples of use of jwt.Decode highlight two examples:
decoded = jwt.decode(encoded, public_key, algorithms='RS256')
-
try: jwt.decode('JWT_STRING', 'secret', algorithms=['HS256']) except jwt.ExpiredSignatureError: # Signature has expired
The curious thing is the parameter Algorithms that can either receive an algorithm or a list. At this point, in a code review that a colleague did, we came to this question:
What is the need for a list of algorithms?
The list would be to "try" decode in all forms passed to the Algorithms?
I got the idea!
– Melissa