This function reads from a local or remote YAML file, as set in the environmental variable "secrets_file".

read_secret(property, file = Sys.getenv("secrets_file"))

Arguments

property

the property to read, case-sensitive

file

either a character string naming a file or a connection open for writing

Details

In the secrets file, the property name and value have to be separated with a colon (:), as is intended in YAML files.

The default value for file is the environmental variable "secrets_file".

The file will be read using read_yaml(), which allows almost any local path or remote connection (such as websites).

Examples

# for this example, create a temporary 'secrets' file
my_secrets_file <- tempfile(fileext = ".yaml")
Sys.setenv(secrets_file = my_secrets_file)
writeLines(c("tenant_id: 8fb3c03060e02e89",
             "default_users: user_1"),
           my_secrets_file)

read_secret("tenant_id")
#> [1] "8fb3c03060e02e89"
read_secret("default_users")
#> [1] "user_1"