| Libsecret Library Reference Manual |
|---|
Here's how to lookup a password in the running secret service, like gnome-keyring or ksecretservice.
Each stored password has a set of attributes which are used to lookup the password. If multiple passwords match the lookup attributes, then the one stored most recently is returned.
These examples use the example schema.
This first example looks up a password asynchronously, and is appropriate for GUI applications so that the UI does not block.
from gi.repository import Secret
def on_password_lookup(source, result, unused):
password = Secret.password_lookup_finish(result)
# password will be null, if no matching password found
Secret.password_lookup(EXAMPLE_SCHEMA, { "number": "8", "even": "true" },
None, on_password_lookup)
This next example looks up a password synchronously. The function call will block until the lookup completes. So this is appropriate for non GUI applications.
from gi.repository import Secret
password = Secret.password_lookup_sync(EXAMPLE_SCHEMA, { "number": "8", "even": "true" }, None)
# password will be null, if no matching password found