Skip to content

Commit

Permalink
#54 set keyring default backend to env
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 7, 2021
1 parent e7f0ff2 commit 3fbaa1d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: zen4R
Version: 0.4-3
Date: 2021-07-23
Date: 2021-09-07
Title: Interface to 'Zenodo' REST API
Authors@R: c(
person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")),
Expand Down
5 changes: 3 additions & 2 deletions R/ZenodoManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
ZenodoManager <- R6Class("ZenodoManager",
inherit = zen4RLogger,
private = list(
keyring_backend = keyring::backend_env$new(),
keyring_service = NULL,
url = "https://zenodo.org/api"
),
Expand All @@ -228,7 +229,7 @@ ZenodoManager <- R6Class("ZenodoManager",
private$url = url
if(!is.null(token)) if(nzchar(token)){
private$keyring_service = paste0("zen4R@", url)
keyring::key_set_with_value(private$keyring_service, username = "zen4R", password = token)
private$keyring_backend$set_with_value(private$keyring_service, username = "zen4R", password = token)
deps <- self$getDepositions(size = 1, quiet = TRUE)
if(!is.null(deps$status)) {
if(deps$status == 401){
Expand All @@ -248,7 +249,7 @@ ZenodoManager <- R6Class("ZenodoManager",
getToken = function(){
token <- NULL
if(!is.null(private$keyring_service)){
token <- suppressWarnings(keyring::key_get(private$keyring_service, username = "zen4R"))
token <- suppressWarnings(private$keyring_backend$get(private$keyring_service, username = "zen4R"))
}
return(token)
},
Expand Down
2 changes: 1 addition & 1 deletion R/zen4R.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' Package: \tab zen4R\cr
#' Type: \tab Package\cr
#' Version: \tab 0.4-3\cr
#' Date: \tab 2021-07-23\cr
#' Date: \tab 2021-09-07\cr
#' License: \tab MIT\cr
#' LazyLoad: \tab yes\cr
#' }
Expand Down
2 changes: 1 addition & 1 deletion man/zen4R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/test-all.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(zen4R)

#test environment
zenodo_url <- "https://sandbox.zenodo.org/api"
zenodo_token <- "<token>"
zenodo_token <- "m9OjWbtoB7pWqHzbUbGXX4WtFqB4XezKgMsNp1ppegMwc9SVIUjgKEG8Vx1z"
zenodo_logger <- "DEBUG"
ZENODO <- try(ZenodoManager$new(url = zenodo_url, token = zenodo_token, logger = zenodo_logger))

Expand Down

0 comments on commit 3fbaa1d

Please sign in to comment.