DataONEorg / scythe

Scythe, the data citation harvester
Other
7 stars 2 forks source link

set up API key config file and a way to load it #4

Closed jeanetteclark closed 3 years ago

jeanetteclark commented 4 years ago

Two steps here:

Not sure if we should load the keys through a helper function or set the package up to load the file automatically

MayaSamet commented 4 years ago

Does the .Renviron solve this completely?

mbjones commented 4 years ago

Its best not to depend on specific .Renviron setups. Instead, use the options facility to retrieve credentials from the users environment like we do for the dataone package.

`

jeanetteclark commented 4 years ago

Hm. So are you thinking that a user can set the API token either via options(scopus_key = ...) or a user can add that line to their .Rprofile? The SCOPUS query function would then do something like SCOPUSKEY <- getOption("scopus_key") to retrieve it.

I do want to find a way to make it easy to not have to set it every time. Unlike dataone the keys don't expire, and they are somewhat difficult to track down on the SCOPUS website (at least compared to the Arctic Data Center), so retrieving one for every R session sounds annoying. That is why I was thinking of the .Renviron approach and setting it as an environment variable as opposed to an option.

Also: https://twitter.com/jennybryan/status/668908727852896256

jeanetteclark commented 4 years ago

Summary of slack discussion:

I got a keyring helper function set up scythe_set_key() as a wrapper around the keyring functions.

Disadvantages so far are:

To dos:

MayaSamet commented 4 years ago

I can rewrite the readme

mbjones commented 4 years ago

For testing on Travis and related platforms, they have a facility for including encrypted keys to be used as secrets. See: https://docs.travis-ci.com/user/encryption-keys/ and https://cran.r-project.org/web/packages/httr/vignettes/secrets.html#travis Of course, Travis itself has access to those keys, so I wouldn't be pushing the nuclear football codes up there.

jeanetteclark commented 3 years ago

I switched to github actions, and have set up the two API keys as secrets in the repo. They are passed via environmental variables to the functions that need them by the config file. It is a bit of a backdoor route to the auth when we would prefer users to use keyring, but we can choose whether we document that or not

R CMD check is passing!