Represents a Bearer Token used for authentication.
The AccessToken
class additionally provides methods to check the token’s expiration
status and the time remaining before it expires.
- Parameters:
token (str
) – The access token string used for authentication.
expires (datetime
) – The expiration datetime of the token. The default is set to January 1, 1970.
-
property is_expired: bool[source]
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.
- Return type:
bool
-
property seconds_remaining: int[source]
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