sanic_jwt_extended.utils module¶
-
sanic_jwt_extended.utils.
create_access_token
(app, identity, user_claims=None, role=None, fresh=False, expires_delta=None)[source]¶ Create a new access token.
Parameters: - app – A Sanic application from request object
- identity – The identity of this token, which can be any data that is json serializable. It can also be a python object
- user_claims – User made claims that will be added to this token. it should be dictionary.
- role – A role field for RBAC
- fresh – If this token should be marked as fresh, and can thus access
fresh_jwt_required()
endpoints. Defaults to False. This value can also be a datetime.timedelta in which case it will indicate how long this token will be considered fresh. - expires_delta – A datetime.timedelta for how long this token should last before it expires. Set to False to disable expiration. If this is None, it will use the ‘JWT_ACCESS_TOKEN_EXPIRES` config value
Returns: An encoded access token
-
sanic_jwt_extended.utils.
create_refresh_token
(app, identity, user_claims=None, expires_delta=None)[source]¶ Create a new refresh token.
Parameters: - app – A Sanic application from request object
- identity – The identity of this token, which can be any data that is json serializable. It can also be a python object
- user_claims – User made claims that will be added to this token. it should be dictionary.
- expires_delta – A datetime.timedelta for how long this token should last before it expires. Set to False to disable expiration. If this is None, it will use the ‘JWT_REFRESH_TOKEN_EXPIRES` config value
Returns: An encoded access token