Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(How) is it possible to list keyrings/keys? #151

Closed
jaraco opened this issue Feb 24, 2015 · 3 comments
Closed

(How) is it possible to list keyrings/keys? #151

jaraco opened this issue Feb 24, 2015 · 3 comments
Labels

Comments

@jaraco
Copy link
Owner

@jaraco jaraco commented Feb 24, 2015

Hi there,

I maintain a little script ( https://github.com/mnagel/gnome-keyring-dumper ) that lists all keys in all keyrings for gnome keyring. Unfortunately it does not longer work with python3 and the most promising way to go I found is to use the python-keyring lib.

(How) is it possible to list keyrings/keys using python-keyring so I can change my keyring dumper to use python-keyring?

Best Regards
Michael


@jaraco

This comment has been minimized.

Copy link
Owner Author

@jaraco jaraco commented Feb 24, 2015

The current API does not provide a way to enumerate keys. I'd invite a pull request to support such functionality (even for only some keyrings).


Original comment by: Jason R. Coombs

@jaraco

This comment has been minimized.

Copy link
Owner Author

@jaraco jaraco commented Feb 24, 2015

If the system keyring is GNOME Keyring, you can use SecretStorage module (which is usually the default Python-Keyring backend on GNOME).

For example:

:::python3
import secretstorage
bus = secretstorage.dbus_init()
collection = secretstorage.get_default_collection()
for item in collection.get_all_items():
    print(item.get_label())
    print(item.get_attributes())

Instead of using get_all_items() you can also specify a filter using search_items() method. See the documentation for details.

Also, you can use GNOME’s libgnome-keyring (the legacy library) and libsecret (the new library) in Python via GObject introspection.


Original comment by: Dmitry Shachnev

@BhasherBEL

This comment has been minimized.

Copy link

@BhasherBEL BhasherBEL commented Jul 1, 2019

for item in keyring.get_keyring().get_preferred_collection().get_all_items():
    print(item.get_label(), item.get_attributes())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.