kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.64k stars 263 forks source link

Keyring is Locked on Ubuntu #264

Closed yw-ucsb closed 1 year ago

yw-ucsb commented 1 year ago

Hi, I've been trying to utilize yagmail on a linux server (Ubuntu 20.04.2 LTS) via ssh connection (with a public key). It works well if I explicitly provide username and password. However when I try to setup the keyring I encountered the following error:

File "/home/yuwang/anaconda3/envs/RL/lib/python3.9/site-packages/keyring/backends/SecretService.py", line 67, in get_preferred_collection raise KeyringLocked("Failed to unlock the collection!") keyring.errors.KeyringLocked: Failed to unlock the collection!

I've tried to follow the guide in Using Keyring on headless Linux systems. The keyring successfully got unlocked, however, once I terminate the dbus session and try once again in a normal terminal, the error occurs again. (Note, this will happen whether I first unlock in the normal terminal with: echo -n 'mypasswd' | gnome-keyring-daemon --unlock, or directly run yagmail.SMTP('username'). -> looks like even if I unlock the keyring once, it got unlocked immediately out of the dbus session.

I'm wondering if this is an issue coming from the ssh connection to a remote server.

Thanks for reading this and any suggestions or feedbacks are highly appreciated.

kootenpv commented 1 year ago

Yeah, I would personally recommend not using the keyring and instead opt for an application specific password these days.

yw-ucsb commented 1 year ago

Thanks for your feedback! I'll just try with specified username and password.