Utility Functions¶
This module contains useful utility functions.
-
jwt_decode_handler
(token)¶ Decodes a JSON Web Token (JWT).
Notes
- Aids debugging by logging an exception if
InvalidTokenError
is raised when decoding fails. - Requires “exp” and “iat” claims to be present in the token’s payload.
Examples
Use with djangorestframework-jwt, by changing your Django settings:
JWT_AUTH = { 'JWT_DECODE_HANDLER': 'edx_rest_framework_extensions.utils.jwt_decode_handler', }
Parameters: token (str) – JWT to be decoded.
Returns: Decoded JWT payload.
Return type: dict
Raises: MissingRequiredClaimError
– Either the exp or iat claims is missing from the JWT payload.InvalidTokenError
– Decoding fails.
- Aids debugging by logging an exception if