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 to get secret from gnome online account #610

Closed
bioinfornatics opened this issue Dec 7, 2022 · 2 comments
Closed

How to get secret from gnome online account #610

bioinfornatics opened this issue Dec 7, 2022 · 2 comments

Comments

@bioinfornatics
Copy link

Dear teams,
after read both keyring documentation and gnome documentation
it is still unclear to me how to list all secrets and how to retrieve a secret link to a gnome online account.

current pointer that help but not enoughs:

the current documentation describe only how to retrieve the system password from the logged user.

$ gnome-keyring-daemon with --unlock
mypasswd
ctrl+d
import keyring
keyring.get_password("system", "<$USER>")

Thanks for your help

@jaraco
Copy link
Owner

jaraco commented Dec 7, 2022

Keyring doesn't support listing all secrets. It also has no integration into gnome online specifics. To the extent that keyring is picking up Gnome keyring as the backend, you can get/set/delete passwords in Gnome keyring, and if Gnome keyring is configured to integrate with an online service, changes made by keyring may be reflected in an online account, but keyring doesn't do anything specifically for that.

Let me know if that doesn't answer your questions.

@bioinfornatics
Copy link
Author

bioinfornatics commented Dec 7, 2022

Thanks @jaraco

I was able to list secrets through the code below:

import secretstorage
connection = secretstorage.dbus_init()
collection = secretstorage.get_collection_by_alias(connection, 'login')
items=list(sorted(collection.get_all_items(), key=lambda i: i.get_label()))
for i in items:
     print('------')
     print(i.get_label())
     print(i.item_path)
     print(i.get_attributes())

which could give

------
Données d’authentification GOA imap_smtp pour l’identité account_1899113806_1
/org/freedesktop/secrets/collection/login/9
{'goa-identity': 'imap_smtp:gen0:account_1899113806_1', 'xdg:schema': 'org.gnome.OnlineAccounts'}
------
Password for 'foobar' on 'system'
/org/freedesktop/secrets/collection/login/17
{'application': 'Python keyring library', 'service': 'system', 'username': 'foobar', 'xdg:schema': 'org.freedesktop.Secret.Generic'}

So I think that the second result can explain the ability to use keyring as the service is system and username foobar

import keyring
keyring.get_password("system", "foobar")

But I do not found yet how to retrieve password from gnome online account as they are no service provided from the attributes properties (i.get_attributes())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants