if (FALSE) {
## Set secret key using `keyring` (preferred method)
keyring::key_set_with_value("plumber_api", plumber::random_cookie_key())
# Load a plumber API
plumb_api("plumber", "01-append") %>%
# Add cookie support via `keyring`
pr_cookie(
keyring::key_get("plumber_api")
) %>%
pr_run()
#### -------------------------------- ###
## Save key to a local file
pswd_file <- "normal_file.txt"
cat(plumber::random_cookie_key(), file = pswd_file)
# Make file read-only
Sys.chmod(pswd_file, mode = "0600")
# Load a plumber API
plumb_api("plumber", "01-append") %>%
# Add cookie support and retrieve secret key from file
pr_cookie(
readLines(pswd_file, warn = FALSE)
) %>%
pr_run()
}
Run the code above in your browser using DataLab