1

I receive the following error...

Error in b_wincred_i_get(target) : 
Windows credential store error in 'get': Element not found.

...when running the following script in R v3.5.1 (R Studio v1.1.456) and keyring v1.1.0. I'm attempting this on a new setup so not sure if this could be as simple as a firewall issue or the like. The script errors out when attempting to get the password (key_get(json_data$service, json_data$user)). I've tried manually plugging in the service and username into the key_get method (instead of using the variables from the config file) but get the same error. The config file is a json file that holds all of the connection details except the password, which obviously gets retrieved from the Windows Credentials Vault. Any help in figuring out a fix for this is greatly appreciated.

library(RJDBC)
library(keyring)
library(jsonlite)

postgres.connection <- function(json_data){

  print("Creating Postgres driver...")
  pDriver <- JDBC(driverClass=json_data$driver, classPath="C:/Users/Drivers/postgresql-42.2.4.jar")

  print("Connecting to Postgres...")
  server <- paste("jdbc:postgresql://", json_data$host, ":", json_data$port, "/", json_data$dbname, sep="")
  pConn <- dbConnect(pDriver, server, json_data$user, key_get(json_data$service, json_data$user))

  return(pConn)

}

json_data <- fromJSON("C:/Users/Configs/Config.json", simplifyVector = TRUE, simplifyDataFrame = TRUE)
json_data_connection <- json_data$postgres$local_read
pc <- postgres.connection(json_data_connection)
Michael Lihs
  • 7,460
  • 17
  • 52
  • 85
bclark
  • 21
  • 4

1 Answers1

0

You mentioned it's a new setup. Is the password already in credentials? To check, go to 'Control Panel'>'User Accounts'>'Credential Manager'>'Windows Credentials', is it under 'Generic Credentials'? I can get the same error by running: key_get('not-valid-service', 'some-user')

Dan T.
  • 11
  • 2