Verifies a JWT string’s signature and validates reserved claims.
Parameters: |
|
---|---|
Returns: |
|
Return type: | dict |
Raises: |
|
Examples
>>> payload = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
>>> jwt.decode(payload, 'secret', algorithms='HS256')
Encodes a claims set and returns a JWT string.
JWTs are JWS signed objects with a few reserved claims.
Parameters: |
|
---|---|
Returns: | The string representation of the header, claims, and signature. |
Return type: | str |
Raises JWTError: | |
If there is an error encoding the claims. |
Examples
>>> jwt.encode({'a': 'b'}, 'secret', algorithm='HS256')
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
Returns the decoded claims without verification of any kind.
Parameters: | token (str) – A signed JWT to decode the headers from. |
---|---|
Returns: | The dict representation of the token claims. |
Return type: | dict |
Raises JWTError: | |
If there is an exception decoding the token. |
Returns the decoded headers without verification of any kind.
Parameters: | token (str) – A signed JWT to decode the headers from. |
---|---|
Returns: | The dict representation of the token headers. |
Return type: | dict |
Raises JWTError: | |
If there is an exception decoding the token. |
Returns the decoded headers without verification of any kind.
This is simply a wrapper of get_unverified_header() for backwards compatibility.
Parameters: | token (str) – A signed JWT to decode the headers from. |
---|---|
Returns: | The dict representation of the token headers. |
Return type: | dict |
Raises JWTError: | |
If there is an exception decoding the token. |