wxc_sdk.tokens module

Simple implementation of Webex tokens

class wxc_sdk.tokens.Tokens(*, access_token: str | None = None, expires_in: int | None = None, expires_at: datetime | None = None, refresh_token: str | None = None, refresh_token_expires_in: int | None = None, refresh_token_expires_at: datetime | None = None, token_type: Literal['Bearer'] | None = None, scope: str | None = None)[source]

Bases: BaseModel

Webex tokens

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

access_token: str | None

access token

expires_in: int | None

remaining lifetime at time of token creation

expires_at: datetime | None

expiration, calculated at time of token creation

refresh_token: str | None

refresh token

refresh_token_expires_in: int | None
refresh_token_expires_at: datetime | None

expiration, calculated at time of token creation

token_type: Literal['Bearer'] | None
scope: str | None
update(new_tokes: Tokens)[source]

Update with values from new tokens

Parameters:

new_tokes (Tokens) – tokens instance to be used as source

set_expiration()[source]

Set expiration based on current time and expires in values

property remaining: int

remaining lifetime in seconds

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'access_token': FieldInfo(annotation=Union[str, NoneType], required=False), 'expires_at': FieldInfo(annotation=Union[datetime, NoneType], required=False), 'expires_in': FieldInfo(annotation=Union[int, NoneType], required=False), 'refresh_token': FieldInfo(annotation=Union[str, NoneType], required=False), 'refresh_token_expires_at': FieldInfo(annotation=Union[datetime, NoneType], required=False), 'refresh_token_expires_in': FieldInfo(annotation=Union[int, NoneType], required=False), 'scope': FieldInfo(annotation=Union[str, NoneType], required=False), 'token_type': FieldInfo(annotation=Union[Literal['Bearer'], NoneType], required=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.