View source: R/setLabKeyDefaults.R
| setLabKeyDefaults | R Documentation |
Sets up the credentials that getDemographics (and any other
Rlabkey call) uses to authenticate against the LabKey EHR server. An
API key, when available, is preferred; otherwise the function falls back to
a .netrc/_netrc file; when neither is present it stops with an
actionable error rather than letting Rlabkey fail later with an opaque
message.
setLabKeyDefaults(siteInfo = getSiteInfo())
siteInfo |
list of site information as returned by
|
The API key is sourced, in order of precedence, from
the environment variable NPRCGENEKEEPR_LABKEY_APIKEY, then
an apiKey entry in the nprcgenekeepr configuration file.
When an API key is found, labkey.setDefaults is called
with that key and siteInfo$baseUrl. When no API key is found, the
function checks for a netrc file (the NETRC environment variable,
then the home-directory .netrc on non-Windows or _netrc on
Windows) and, if present, leaves Rlabkey to use it. The API key is
never read from or written to the package sources; keep it in the
environment, the configuration file, or the netrc file only.
Invisibly, a list with elements method (one of
"apiKey" or "netrc") and baseUrl. Stops with an error
when no credential can be found.
## Not run:
## Requires an apiKey (env var or config) or a .netrc file to succeed.
library(nprcgenekeepr)
result <- tryCatch(
setLabKeyDefaults(getSiteInfo(expectConfigFile = FALSE)),
error = function(e) conditionMessage(e)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.