jaraco / keyring

MIT License
1.26k stars 159 forks source link

Keyring not retrieving password with get_password #627

Closed Boston-of-Gilead closed 1 year ago

Boston-of-Gilead commented 1 year ago

Describe the bug Fresh install of Keyring not sending get_password to terminal. The credential appears in Credential Locker so set_password is working correctly.

To Reproduce My code:

import keyring
keyring.set_password("TEST", "username", "password") 
keyring.get_password("TEST", "username") 
print("some string")

The output:

PS C:\Users\<username>> & "C:/Program Files/Python310/python.exe" c:/Users/<username>/path/to/script/Keyring.py
some string
PS C:\Users\<username>> 

Expected behavior

PS C:\Users\<username>> & "C:/Program Files/Python310/python.exe" c:/Users/<username>/path/to/script/Keyring.py
'password'
some string
PS C:\Users\<username>> 

Environment

C:\Users\<username>>pip list | findstr "keyring"
keyring            23.13.1
...
C:\Users\<username>>keyring --list-backends
keyring.backends.Windows.WinVaultKeyring (priority: 5)
keyring.backends.chainer.ChainerBackend (priority: -1)
keyring.backends.fail.Keyring (priority: 0)
...

Additional context Add any other context about the problem here. Windows Credential Manager gets the entry: image

Boston-of-Gilead commented 1 year ago

Ok I've sort of fixed it.

Reinstalling Keyring - ineffective. Reinstalling Python - ineffective. Reinstalling VSCode - ineffective. Switching to PyCharm - ineffective.

I noticed WSL (Windows Subsystem for Linux) updated itself yesterday. I removed the update through appwiz - ineffective.

My work computer had bizarre networking issues from when I had WSL installed on it so I removed WSL - effective.

However my Keyring doesn't behave the same as the docs say. keyring.get_password('TEST2','username') Doesn't return anything. However this now works (it wasn't before):

CRED = keyring.get_password('TEST2','username') 
print(CRED)

Same for keyring.get_keyring() and keyring.get_credential('TEST2','username') which weren't working before either, but now will work as long as I set them to a variable after having WSL uninstalled, despite Python, Keyring, IDLE, and various IDEs all running on Windows.

I suppose going forward I'll have to keep my Docker/Linux activity on dedicated VMs rather than creating containers via WSL... and use variables for the Keyring contents.