CredentialStore
Server credentials persisted as JSON in the user's config directory.
Attributes
attributepathPathReturn the location of the credentials file.
Functions
func__init__(self, path=None, persist=None) -> NoneInitialize the store and load any credentials already on disk.
paramselfparampathPath | None= NoneLocation of the credentials file.
parampersistbool | None= NoneWhether to read and write the file. Defaults to reading
KITARU_DISABLE_CREDENTIALS_CACHE.
Returns
Nonefuncget(self, url) -> ServerCredentials | NoneReturn the credentials stored for a server.
paramselfparamurlstrServer base URL.
Returns
ServerCredentials | NoneStored credentials, or None when the server is unknown.
funclist(self) -> list[ServerCredentials]Return the credentials of every known server.
paramselfReturns
listStored credentials, ordered by server URL.
funcget_token(self, url, allow_expired=False) -> ApiToken | NoneReturn the cached token of a server.
paramselfparamurlstrServer 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(self, 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.
paramselfparamurlstrServer 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(self, url, api_key, type=ApiType.SERVER) -> NoneStore an API key for a server and drop the token it replaces.
paramselfparamurlstrServer base URL.
paramapi_keystrAPI key to store.
paramtypeApiType= ApiType.SERVERAPI type.
Returns
Nonefuncset_device(self, url, device_id, device_code) -> NoneStore a device authorization for a server.
paramselfparamurlstrServer base URL.
paramdevice_iduuid.UUIDId of the authorized device.
paramdevice_codestrDevice code the client polls with.
Returns
Nonefuncget_control_plane(self, control_plane_api_url) -> ServerCredentials | NoneReturn the credentials stored for a control plane.
paramselfparamcontrol_plane_api_urlstrControl plane API base URL.
Returns
ServerCredentials | NoneStored credentials, or None when the entry is missing or is not a
funcclear_token(self, url) -> NoneDrop the cached token of a server, keeping the way to get a new one.
paramselfparamurlstrServer base URL.
Returns
Nonefuncclear(self, url) -> NoneDrop every credential stored for a server.
paramselfparamurlstrServer base URL.
Returns
Nonefuncclear_all(self) -> NoneDrop every stored credential and remove the credentials file.
paramselfReturns
None