Closed cderv closed 6 years ago
I too get this error on Windows:
key_set_with_value("system", Sys.getenv("USERNAME"), "password")
keyring_list()
#> Error in FUN(X[[i]], ...) : subscript out of bounds
R version R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)
Keyring version 1.0.0
Can you access the credentials using Credential Manager?
Yes I can access credentials. Following traceback after the error. The issue is in keyring::b_wincred_i_parse_target
The issue is here, line 57 https://github.com/r-lib/keyring/blob/7fe8d9a0f7ee6a2a86fd286d16237a5f9b1f9c06/R/backend-wincred.R#L52-L59 Some parts retrieve from the windows credentials manager have only 1 element, i.e only a keyring and no a service. Those credentials are already present in the windows cred store, and are not created with {keyring}.
So vapply(parts, "[[", "", 2)
returns an error. If you do like for username
, it is working.
data.frame(stringsAsFactors = FALSE,
keyring = vapply(parts, "[[", "", 1),
service = vapply(parts, function(x) x[2][[1]] %||%
"", ""),
username = vapply(parts, function(x) x[3][[1]] %||%
"", ""))
The issue is with the extractor function. Here a (not so small) reprex
devtools::dev_mode(on = TRUE)
#> Dev mode: ON
# All the type of credential I have registered in my credential store
list_cred <- c(
"keyring::username",
"keyring::",
"keyring",
"keyring:service:username",
"keyring:service",
":service:username")
# This is the issue
parts <- keyring:::b_wincred_i_parse_target(list_cred)
#> Error in FUN(X[[i]], ...): indice hors limites
# It is just an issue of extraction function to get the element when it does no exist
parts <- lapply(strsplit(list_cred, ":"), lapply, keyring:::b_wincred_i_unescape)
new_b_wincred_i_parse_target <- function (target) {
parts <- lapply(strsplit(target, ":"), lapply, keyring:::b_wincred_i_unescape)
# to load the operator
`%||%` <- keyring:::`%||%`
# extraction function
extract <- function(x, i) x[i][[1]] %||% ""
res <- data.frame(stringsAsFactors = FALSE,
keyring = vapply(parts, extract, "", 1),
service = vapply(parts, extract, "", 2),
username = vapply(parts, extract, "", 3))
}
# this is now working
parts <- new_b_wincred_i_parse_target(list_cred)
parts
#> keyring service username
#> 1 keyring username
#> 2 keyring
#> 3 keyring
#> 4 keyring service username
#> 5 keyring service
#> 6 service username
Created on 2018-07-14 by the reprex package (v0.2.0).
If you need further information, or wants me to do a PR with this, please tell me.
Thanks much, fixed in dev, going to CRAN ASAP!
You are right, it is faster ! Thanks !
Hi,
Trying to use
keyring_list
on windows, I notice this error:not sure why and from where it could come from.
Session Info
```r devtools::session_info("keyring") #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.1 (2017-06-30) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate French_France.1252 #> tz Europe/Paris #> date 2017-09-18 #> Packages ----------------------------------------------------------------- #> package * version date source #> assertthat 0.2.0 2017-04-11 CRAN (R 3.4.0) #> getPass 0.2-2 2017-07-21 CRAN (R 3.4.1) #> keyring 1.0.0 2017-09-18 Github (r-lib/keyring@cb933bd) #> openssl 0.9.7 2017-09-06 CRAN (R 3.4.1) #> R6 2.2.2 2017-06-17 CRAN (R 3.4.0) #> rstudioapi 0.7 2017-09-09 Github (rstudio/rstudioapi@517d438) #> tools 3.4.1 2017-06-30 local #> utils * 3.4.1 2017-06-30 local ```