class splatnet3_scraper.auth.Token

Class that represents a token. This class is meant to store the token itself, the type of token it is, and the time it was created. It can be used to check if the token is expired or display the time left before it expires. It also provides convenience methods for getting all sorts of metadata about the token.

Constructors

Token(value, name, timestamp)

Initializes a Token object. The expiration time is calculated based on the token type, with a default of 1e10 seconds (about 316 days, this should be basically forever for all intents and purposes; if you have a python session running for that long, you have bigger problems than a token expiring).

String representation

__repr__()

Return repr(self).

Properties

property time_left : float

Returns the time left before the token expires. If the token is expired, a negative number will be returned. This is not a guarantee that the token is expired, but it is a good indicator that it is for most cases.

property time_left_str : str

A string representation of the time left before the token expires. If the token is expired, “Expired” will be returned. This is not a guarantee that the token is expired, but it is a good indicator that it is for most cases. If the time left is greater than 100,000 hours, “basically forever” will be returned. If you have a python session running for that long, you have bigger problems than a token expiring.

Attributes

property is_expired : bool

Checks if the token is expired. This is done by comparing the current time to the expiration time of the token. If the current time is greater than the expiration time, the token is expired. This is not a guarantee that the token is expired, but it is a good indicator that it is for most cases.

property is_valid : bool

A very rudimentary check to see if the token is valid. This is not a guarantee that the token is valid, but it is a good indicator that it is for most cases. It checks if the token is not None and if it is not an empty string. This usually means that the token is valid, but it is not a guarantee. This is also here in case a future version of the API requires a different check to determine if a token is valid.