Allow keyring package to use env backend for API tokens
Change-Id: Idffd9a5c90499be824dfea16cb52045ce9b836a3
diff --git a/R/KorAPConnection.R b/R/KorAPConnection.R
index b152b00..a5ac7d9 100644
--- a/R/KorAPConnection.R
+++ b/R/KorAPConnection.R
@@ -120,9 +120,9 @@
#' @import keyring
getApiToken <- function(KorAPUrl) {
- if ("keyring" %in% installed.packages()[,1 ] && has_keyring_support()
- && tryCatch(KorAPUrl %in% key_list(service = apiTokenServiceName), error = function(e) warning(e), finally = { return(NULL) }))
- key_get(apiTokenServiceName, KorAPUrl)
+ keyList <- key_list(service = apiTokenServiceName)
+ if (KorAPUrl %in% keyList)
+ key_get(apiTokenServiceName, KorAPUrl)
else
NULL
}