Skip to content

Commit ffa8458

Browse files
vimallocjpadilla
authored andcommitted
Add 'algorithms=[]' kwargs to jwt.decode() examples
Added because of this commit: 11f30c4
1 parent 74399b1 commit ffa8458

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Example Usage
2525
>>> jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')
2626
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg'
2727
28-
>>> jwt.decode('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg', 'secret')
28+
>>> jwt.decode('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg', 'secret', algorithms=['HS256'])
2929
{'some': 'payload'}
3030
3131
See :doc:`Usage Examples <usage>` for more examples.

docs/usage.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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`
105105
instance 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

Comments
 (0)