You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,16 @@ You can still get the payload by setting the `verify` argument to `False`.
43
43
jwt.decode('someJWTstring', verify=False)
44
44
```
45
45
46
+
The `decode()` function can raise other exceptions, e.g. for invalid issuer or audience (see below). All exceptions that signify that the token is invalid extend from the base `InvalidTokenError` exception class, so applications can use this approach to catch any issues relating to invalid tokens:
47
+
48
+
```python
49
+
try:
50
+
payload = jwt.decode('someJWTstring')
51
+
except jwt.InvalidTokenError:
52
+
pass# do something sensible here, e.g. return HTTP 403 status code
53
+
```
54
+
55
+
46
56
## Algorithms
47
57
48
58
The JWT spec supports several algorithms for cryptographic signing. This library
If the issuer claim is incorrect, `jwt.InvalidIssuerError` will be raised.
201
+
202
+
190
203
### Audience Claim
191
204
192
205
> The aud (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the aud claim when this claim is present, then the JWT MUST be rejected. In the general case, the aud value is an array of case-sensitive strings, each containing a StringOrURI value. In the special case when the JWT has one audience, the aud value MAY be a single case-sensitive string containing a StringOrURI value. The interpretation of audience values is generally application specific. Use of this claim is OPTIONAL.
0 commit comments