snip.token.storage

Token storage module.

This module provides different solutions for tokens.

Functions

get_all_tokens([keyring, files])

Get all tokens from all sources.

get_token_by_deployment(deployment_url[, ...])

Get the token for a specific deployment_url.

get_tokens_by_book_and_deployment(book_id, ...)

Get all tokens for a specific book_id and deployment_url.

Modules

file_store

Functionalities to save and retrieve tokens from ini files.

keyring_store

Functionalities to save and retrieve tokens from a keyring.

Module Functions

snip.token.storage.get_all_tokens(keyring: KeyringBackend | None = None, files: str | PathLike | Sequence[str | PathLike] | None = None) tuple[list[Token], Iterable[str | PathLike]]

Get all tokens from all sources.

Parameters:
  • keyring (KeyringBackend, optional) – The keyring to use. Supply to override the default keyring. Defaults to None.

  • files (Files, optional) – The files to read the tokens from. Supply to override the default files. Defaults to None.

Returns:

tokens, sources – List of all tokens and their sources.

Return type:

(List[Token], List[str])

snip.token.storage.get_token_by_deployment(deployment_url: str | None, keyring: KeyringBackend | None = None, files: str | PathLike | Sequence[str | PathLike] | None = None) tuple[list[Token], list[str | PathLike]]

Get the token for a specific deployment_url.

Parameters:
  • deployment_url (str) – The deployment_url to get the token for.

  • keyring (KeyringBackend, optional) – The keyring to use. Defaults to None.

  • files (Files, optional) – The files to read the tokens from. Defaults to None.

Returns:

tokens, sources – List of all tokens and their sources.

Return type:

(List[Token], List[str])

snip.token.storage.get_tokens_by_book_and_deployment(book_id: str | int, deployment_url: str | None, keyring: KeyringBackend | None = None, files: str | PathLike | Sequence[str | PathLike] | None = None) tuple[list[BookToken], list[str | PathLike]]

Get all tokens for a specific book_id and deployment_url.

Parameters:
  • book_id (str) – The book_id to get the tokens for.

  • deployment_url (str, optional) – The deployment_url to get the tokens for.

  • keyring (KeyringBackend, optional) – The keyring to use. Defaults to None.

  • files (Files, optional) – The files to read the tokens from. Defaults to None.

Returns:

tokens, sources – List of all tokens and their sources.

Return type:

(List[Token], List[str])