r-lib / keyring

:closed_lock_with_key: Access the system credential store from R
https://keyring.r-lib.org/
Other
196 stars 28 forks source link

Keyring `system` does not exist with backend_file #68

Closed ras44 closed 5 years ago

ras44 commented 5 years ago

I receive the error Keyring 'system' does not exist when setting a value:

reprex:

library(keyring)

kr_name <- "my_credentials"
kr_service <- "my_service"
kr_username <- "my_username"

kb <- keyring::backend_file$new()
kb$keyring_create(kr_name)
kb$set_with_value(kr_service, kr_username)
kb$keyring_lock(kr_name)
cderv commented 5 years ago

You get the message because it is looking for the default keyring that does not exist

kb$set_with_value(kr_service, kr_username)

There is a missing keyring argument here because you do not use the default one, but your kr_name keyring. Also set_with_value is for non interactive use and expect a password argument. Use set for interactive registration. This line should be kb$set_with_value(kr_service, kr_username, password, keyring = kr_name)

To create the default system keyring named system, use kb$keyring_create()

Use kb$keyring_list() to see the already existing keyring.

ras44 commented 5 years ago

Thank you, that fixed it.

Would it be helpful to include a vignette or backend_file example? I would be happy to provide a PR with something along the lines of the above. Currently the examples in the documentation for key_set and key_set_with_value only use the default keyring.

gaborcsardi commented 5 years ago

@ras44 yes, that would make sense.

cderv commented 5 years ago

@gaborcsardi FWIW this should have been closed by #69 I think.

gaborcsardi commented 5 years ago

Thanks!

nielsenmarkus11 commented 4 years ago

@gaborcsardi, because this doesn't have a "default" backend does that mean we can't have the OS automatically unlock it?

gaborcsardi commented 4 years ago

The OS can only unlock keyrings that it knows about, so yeah, I am afraid that it cannot automatically unlock the file backend.