diff --git a/DESCRIPTION b/DESCRIPTION index 6a6d4cd5..150c75d1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,6 +36,7 @@ Suggests: httpuv, jose, jsonlite, + keyring, knitr, later (>= 1.4.0), paws.common, diff --git a/R/secret.R b/R/secret.R index e0f9cf95..4a41e21c 100644 --- a/R/secret.R +++ b/R/secret.R @@ -160,6 +160,13 @@ secret_has_key <- function(key) { } secret_get_key <- function(envvar, call = caller_env()) { + if (is_installed("keyring")) { + key <- tryCatch(keyring::key_get(envvar), error = function(e) NULL) + if (!is.null(key)) { + return(key) + } + } + key <- Sys.getenv(envvar) if (identical(key, "")) { diff --git a/tests/testthat/test-curl.R b/tests/testthat/test-curl.R index 225983a4..53355ed0 100644 --- a/tests/testthat/test-curl.R +++ b/tests/testthat/test-curl.R @@ -134,7 +134,7 @@ test_that("can translate data", { expect_snapshot({ curl_translate("curl http://example.com --data abcdef") - curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain") + curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain") |> }) })