Returns the decoded claims without verification of any kind.
Parameters: | token (str) – A signed JWS to decode the headers from. |
---|---|
Returns: | The str representation of the token claims. |
Return type: | str |
Raises JWSError: | |
If there is an exception decoding the token. |
Returns the decoded headers without verification of any kind.
Parameters: | token (str) – A signed JWS to decode the headers from. |
---|---|
Returns: | The dict representation of the token headers. |
Return type: | dict |
Raises JWSError: | |
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 JWS to decode the headers from. |
---|---|
Returns: | The dict representation of the token headers. |
Return type: | dict |
Raises JWSError: | |
If there is an exception decoding the token. |
Signs a claims set and returns a JWS string.
Parameters: |
|
---|---|
Returns: | The string representation of the header, claims, and signature. |
Return type: | str |
Raises JWSError: | |
If there is an error signing the token. |
Examples
>>> jws.sign({'a': 'b'}, 'secret', algorithm='HS256')
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
Verifies a JWS string’s signature.
Parameters: |
|
---|---|
Returns: | The str representation of the payload, assuming the signature is valid. |
Return type: | str |
Raises JWSError: | |
If there is an exception verifying a token. |
Examples
>>> token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
>>> jws.verify(token, 'secret', algorithms='HS256')