-
Couldn't load subscription status.
- Fork 14
Open
Description
I'm attempting to store a username and a password for a specific service. As far as I can understand the get_credential function is currently not supported.
Here is my workaround, but I'd like to get rid of it ... ;-)
def _active_backend_name(user_readable=True):
return f"{keyring.get_keyring().__module__}.{type(keyring.get_keyring()).__name__}"
def _get_credential(service: str):
if _active_backend_name() == "keyrings.cryptfile.cryptfile.CryptFileKeyring":
username = keyring.get_password(service, "USERNAME")
if username:
password = keyring.get_password(service, username)
return SimpleCredential(username, password)
else:
return None
else:
return keyring.get_credential(service, None)
def _keyring_set(service: str, cred: SimpleCredential):
if _active_backend_name() == "keyrings.cryptfile.cryptfile.CryptFileKeyring":
keyring.set_password(service, "USERNAME", cred.username)
keyring.set_password(service, cred.username, cred.password)Metadata
Metadata
Assignees
Labels
No labels