Access Token#
- pydantic model AccessToken[source]#
Represents an access token for authentication.
The
AccessToken
class encapsulates the access token string and its expiration time. It provides methods to check the token’s expiration status and the time remaining before it expires.- Parameters:
token (AnyStr) – The access token string used for authentication.
expires (datetime) – The expiration datetime of the token. The default is set to January 1, 1970.
- field expires: datetime [Optional]#
- field token: AnyStr = ''#
- property is_expired: bool#
Checks if the access token is expired.
This property evaluates whether the access token has expired. A token is considered expired if the current time is within 60 seconds of the expiration time.
- Returns:
True
if the token is expired,False
otherwise.- Return type:
bool
- property seconds_remaining: int#
Gets the number of seconds remaining until the token expires.
This property calculates the time remaining before the token expires. If the token is already expired, it returns 0.
- Returns:
The number of seconds remaining until the token expires.
- Return type:
int