I used GnomeKeyring from Gtk3 with Python 2.7 but almost all methodes are deprecated [1]. So I tried to use SecretSecret.Collection [2]
import gi
gi.require_version('Secret', '1.0')
from gi.repository import Secret
>> ValueError: Namespace Secret not available
I found the package "python-secretstorage" [3] and can access the keyring now:
import secretstorage
bus = secretstorage.dbus_init()
collection = secretstorage.get_default_collection(bus) ## login keyring
But how can I find the key I am searching for by label so I dont have to iterate over all item?
items = collection.get_all_items()
for item in items:
if item.get_label() == "most_wanted_key":
return item
Here is what I tried, but it don't works with the label, only with attribute(s).
found_items = collection.search_items({"label": "most_wanted_key"})
- https://lazka.github.io/pgi-docs/GnomeKeyring-1.0/functions.html
- https://lazka.github.io/pgi-docs/Secret-1/classes/Collection.html
- https://secretstorage.readthedocs.io/en/latest/
Update
https://specifications.freedesktop.org/secret-service/ch05.html Chapter 5. Lookup Attributes During a lookup, attribute names and values are matched via case-sensitive string equality. ... In order to search for items, use the SearchItems() method of the Service interface. https://specifications.freedesktop.org/secret-service/re01.html#org.freedesktop.Secret.Service.SearchItems