CredentialStore

Server credentials persisted as JSON in the user's config directory.

Server credentials persisted as JSON in the user's config directory.

Attributes

attributepathPath

Return the location of the credentials file.

Functions

constructor__init__(path=None, persist=None) -> None

Initialize the store and load any credentials already on disk.

parampathPath | None
= None

Location of the credentials file.

parampersistbool | None
= None

Whether to read and write the file. Defaults to reading KITARU_DISABLE_CREDENTIALS_CACHE.

Returns

None
funcget(url) -> ServerCredentials | None

Return the credentials stored for a server.

paramurlstr

Server base URL.

Returns

ServerCredentials | None

Stored credentials, or None when the server is unknown.

funclist() -> list[ServerCredentials]

Return the credentials of every known server.

Returns

list

Stored credentials, ordered by server URL.

funcget_token(url, allow_expired=False) -> ApiToken | None

Return the cached token of a server.

paramurlstr

Server base URL.

paramallow_expiredbool
= False

Whether to return a token inside its leeway window.

Returns

ApiToken | None

Cached token, or None when there is none to return.

funcset_token(url, token, type=None, control_plane_api_url=None) -> None

Cache a token for a server.

The control plane is recorded with the token it issued rather than on its own, because an entry that holds neither a token nor a credential is dropped when the store is written.

paramurlstr

Server base URL.

paramtokenApiToken

Token to cache.

paramtypeApiType | None
= None

API type, left as stored when omitted.

paramcontrol_plane_api_urlstr | None
= None

Control plane that issued the credential behind this token, left as stored when omitted.

Returns

None
funcset_api_key(url, api_key, type=ApiType.SERVER) -> None

Store an API key for a server and drop the token it replaces.

paramurlstr

Server base URL.

paramapi_keystr

API key to store.

paramtypeApiType
= ApiType.SERVER

API type.

Returns

None
funcset_device(url, device_id, device_code) -> None

Store a device authorization for a server.

paramurlstr

Server base URL.

paramdevice_iduuid.UUID

Id of the authorized device.

paramdevice_codestr

Device code the client polls with.

Returns

None
funcget_control_plane(control_plane_api_url) -> ServerCredentials | None

Return the credentials stored for a control plane.

paramcontrol_plane_api_urlstr

Control plane API base URL.

Returns

ServerCredentials | None

Stored credentials, or None when the entry is missing or is not a

funcclear_token(url) -> None

Drop the cached token of a server, keeping the way to get a new one.

paramurlstr

Server base URL.

Returns

None
funcclear(url) -> None

Drop every credential stored for a server.

paramurlstr

Server base URL.

Returns

None
funcclear_all() -> None

Drop every stored credential and remove the credentials file.

Returns

None

On this page