jaraco / keyring

MIT License
1.24k stars 152 forks source link

Receiving keyring.backends.macOS.api.Error: (-25244, 'Unknown Error') #605

Closed liorp closed 1 year ago

liorp commented 1 year ago

Describe the bug Running macOS Ventura. Upon running keyring.set_password(service_id, service_id, f"{username_get}\t{password_get}"), I get keyring.backends.macOS.api.Error: (-25244, 'Unknown Error') I don't know if it's related, but I'm getting a lot of alerts from keychain that ask me to provide to password in order to have access to my keychain for the python script.

To Reproduce Added a code snippet that doesn't work

service_id = "test"
username_get = "test"
password_get = "test"
keyring.set_password(service_id, service_id, f"{username_get}\t{password_get}")

Expected behavior keyring should save the string.

Environment

$ pip list | grep keyring
keyring                                           23.11.0
$ keyring --list-backends
keyring.backends.fail.Keyring (priority: 0)
keyring.backends.macOS.Keyring (priority: 5)
keyring.backends.chainer.ChainerBackend (priority: -1)

Additional context Add any other context about the problem here.

jaraco commented 1 year ago

I have macOS Ventura, and I don't have any problems:

 $ keyring set test jaraco
Password for 'jaraco' in 'test': 
 $ keyring get test jaraco
foo
 $ keyring del test jaraco

I don't know if it's related, but I'm getting a lot of alerts from keychain that ask me to provide to password in order to have access to my keychain for the python script.

It probably is related. I've had intermittent issues on macOS where the keyring fails to unlock with the initial login password, and thereafter every access requires the password to be entered. Typically logging out and logging back in allows those prompts to be suppressed.

As you can see from the error message, the cause is "Unknown". That just means keyring doesn't yet have a cause mapped to that code.

According to this article, that code corresponds to errSecInvalidOwnerEdit. According to this reference, the code means "Invalid attempt to change the owner of this item."

So it seems there's something corrupted or misconfigured about the keychain. You may want to try deleting/recreating the keychain file (after backing it up) or other troubleshooting to repair the situation. Unfortunately, I don't think there's anything more that keyring can do to help.

Good luck and feel free to follow up with further questions or progress.