cmem_client.models.token¤
Authentication token models for OAuth 2.0 flows.
This module provides models for handling OAuth 2.0 tokens, particularly Keycloak tokens used in Corporate Memory authentication. It includes automatic JWT parsing and expiration checking functionality.
The KeycloakToken model handles token lifecycle management, including automatically parsing JWT contents and providing expiration checking to support token refresh logic in authentication providers.
Classes:
- KeycloakToken – A Keycloak token
Functions:
- default_factory_now – Get the current UTC datetime
KeycloakToken¤
Bases: Model
A Keycloak token
Attributes:
- access_token (
str) – The encoded bearer token, as sent in theAuthorizationheader. - expires_in (
int) – Lifetime of the token in seconds, counted from when Keycloak issued it. - expires (
datetime) – When the token expires. Taken from theexpclaim of the decoded token on creation, so the default is never what a caller sees. - jwt (
dict) – Claims of the decoded token. The signature is not verified here, because the token comes straight from the token endpoint over TLS.
Functions:
- is_expired – Check if token is expired
- model_post_init – Do the post init
access_token¤
expires¤
expires_in¤
is_expired¤
Check if token is expired
jwt¤
model_config¤
model_post_init¤
Do the post init
default_factory_now¤
Get the current UTC datetime