nolito.tokens module¶
- class nolito.tokens.KeyringTokenStore(*, service, username, metadata_file)[source]¶
Bases:
objectCreate a token store using the Keyring
- Parameters:
service (
str) – The name of the keyring serviceusername (
str) – The username for the keyring servicemetadata_file (
Path) – The path to the metadata file
- classmethod from_settings(settings)[source]¶
Create the token store based on Nolito settings
- Parameters:
settings (
NolitoSettings) – The Nolito settings- Return type:
- class nolito.tokens.TokenSet(access_token, refresh_token, expires_at, token_type='Bearer', scope=None)[source]¶
Bases:
objectSet of tokens used by the API
- Parameters:
access_token (
str) – The access tokenrefresh_token (
str) – The refresh tokenexpires_at (
int) – The expiration time as a UNIX timestamp (sec)token_type (
str) – The token type (defaults to"Bearer")scope (
str|None) – The token scope (defaults toNone)
- classmethod from_oauth_payload(payload, now=None)[source]¶
Extract the token set from an OAuth payload
- Parameters:
payload (
dict[str,Any]) – The OAuth payload as returned by aPOSTrequest to thetoken/endpoint.now (
int|None) – Current time in seconds (defaults totime.time()whenNone).
- Raises:
RuntimeError – Raised if no
expires_inkey is found.- Return type: