@@ -73,7 +73,7 @@ Expiration time is automatically verified in `jwt.decode()` and raises
7373.. code-block :: python
7474
7575 try :
76- jwt.decode(' JWT_STRING' , ' secret' )
76+ jwt.decode(' JWT_STRING' , ' secret' , algorithms = [ ' HS256 ' ] )
7777 except jwt.ExpiredSignatureError:
7878 # Signature has expired
7979
@@ -99,14 +99,14 @@ you can set a leeway of 10 seconds in order to have some margin:
9999
100100 # JWT payload is now expired
101101 # But with some leeway, it will still validate
102- jwt.decode(jwt_payload, ' secret' , leeway = 10 )
102+ jwt.decode(jwt_payload, ' secret' , leeway = 10 , algorithms = [ ' HS256 ' ] )
103103
104104 Instead of specifying the leeway as a number of seconds, a `datetime.timedelta `
105105instance can be used. The last line in the example above is equivalent to:
106106
107107.. code-block :: python
108108
109- jwt.decode(jwt_payload, ' secret' , leeway = datetime.timedelta(seconds = 10 ))
109+ jwt.decode(jwt_payload, ' secret' , leeway = datetime.timedelta(seconds = 10 ), algorithms = [ ' HS256 ' ] )
110110
111111 Not Before Time Claim (nbf)
112112~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -142,7 +142,7 @@ Issuer Claim (iss)
142142 }
143143
144144 token = jwt.encode(payload, ' secret' )
145- decoded = jwt.decode(token, ' secret' , issuer = ' urn:foo' )
145+ decoded = jwt.decode(token, ' secret' , issuer = ' urn:foo' , algorithms = [ ' HS256 ' ] )
146146
147147 If the issuer claim is incorrect, `jwt.InvalidIssuerError ` will be raised.
148148
@@ -169,7 +169,7 @@ Audience Claim (aud)
169169 }
170170
171171 token = jwt.encode(payload, ' secret' )
172- decoded = jwt.decode(token, ' secret' , audience = ' urn:foo' )
172+ decoded = jwt.decode(token, ' secret' , audience = ' urn:foo' , algorithms = [ ' HS256 ' ] )
173173
174174 If the audience claim is incorrect, `jwt.InvalidAudienceError ` will be raised.
175175
0 commit comments