CredentialStore
Server credentials persisted as JSON in the user's config directory.
Server credentials persisted as JSON in the user's config directory.
Attributes
attributepathPathReturn the location of the credentials file.
Functions
constructor__init__(path=None, persist=None) -> NoneInitialize the store and load any credentials already on disk.
parampathPath | None= NoneLocation of the credentials file.
parampersistbool | None= NoneWhether to read and write the file. Defaults to reading
KITARU_DISABLE_CREDENTIALS_CACHE.
Returns
Nonefuncget(url) -> ServerCredentials | NoneReturn the credentials stored for a server.
paramurlstrServer base URL.
Returns
ServerCredentials | NoneStored credentials, or None when the server is unknown.
funclist() -> list[ServerCredentials]Return the credentials of every known server.
Returns
listStored credentials, ordered by server URL.
funcget_token(url, allow_expired=False) -> ApiToken | NoneReturn the cached token of a server.
paramurlstrServer base URL.
paramallow_expiredbool= FalseWhether to return a token inside its leeway window.
Returns
ApiToken | NoneCached token, or None when there is none to return.
funcset_token(url, token, type=None, control_plane_api_url=None) -> NoneCache 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.
paramurlstrServer base URL.
paramtokenApiTokenToken to cache.
paramtypeApiType | None= NoneAPI type, left as stored when omitted.
paramcontrol_plane_api_urlstr | None= NoneControl plane that issued the credential behind this token, left as stored when omitted.
Returns
Nonefuncset_api_key(url, api_key, type=ApiType.SERVER) -> NoneStore an API key for a server and drop the token it replaces.
paramurlstrServer base URL.
paramapi_keystrAPI key to store.
paramtypeApiType= ApiType.SERVERAPI type.
Returns
Nonefuncset_device(url, device_id, device_code) -> NoneStore a device authorization for a server.
paramurlstrServer base URL.
paramdevice_iduuid.UUIDId of the authorized device.
paramdevice_codestrDevice code the client polls with.
Returns
Nonefuncget_control_plane(control_plane_api_url) -> ServerCredentials | NoneReturn the credentials stored for a control plane.
paramcontrol_plane_api_urlstrControl plane API base URL.
Returns
ServerCredentials | NoneStored credentials, or None when the entry is missing or is not a
funcclear_token(url) -> NoneDrop the cached token of a server, keeping the way to get a new one.
paramurlstrServer base URL.
Returns
Nonefuncclear(url) -> NoneDrop every credential stored for a server.
paramurlstrServer base URL.
Returns
Nonefuncclear_all() -> NoneDrop every stored credential and remove the credentials file.
Returns
None