Gets a password, in this order, from:

get_pass2(user, password = NULL, service, keyring = NULL)

Arguments

user

[character(1)] giving the username to authenticate with, for example "jane". Also used to retrieve from and store the password in keyring.

password

[character(1)] giving the password. Use this to substitute in an environment variable such as Sys.getenv("SECRET"). Recommended only when the environment variable is declared in an encrypted form, and when it is redacted from the logs. Do not expose your passwords in scripts or the R console. Defaults to NULL, in which case the keyring is used.

service

[character(1)] giving the service to authenticate against with user and password, for example "foo-service.com". Also used to retrieve from and store the password in keyring. If a longer URL is provided, the domain is extracted using urltools::domain(), which is the conventional name for storing secrets (for example, "foo-service.com", not "https://foo-service.com/api").

keyring

For systems that support multiple keyrings, specify the name of the keyring to use here. If NULL, then the default keyring is used. See also has_keyring_support().

Details

  1. password, unless it is NULL or "" as for an unset variable.

  2. a password matching user and service in the system's keychain keyring.

  3. an interactive prompt.

Otherwise, an error is thrown.