Description Usage Arguments Details Value Note Author(s) See Also Examples
Get the API key(s). It is usually used in a function call chain that makes use
of Google or Baidu map APIs, e.g., geocode
.
1 2 3 4 5 6 7 8 9 10 11 | getApiKey(app = c("google", "baidu", "gaode", "ipstack", "ipify",
"ipinfo"), overide = FALSE, drop = TRUE, ...)
get_api_key(app = c("google", "baidu", "gaode", "ipstack", "ipify",
"ipinfo"), overide = FALSE, drop = TRUE, ...)
setApiKey(app = c("google", "baidu", "gaode", "ipstack", "ipify",
"ipinfo"), key = NULL, gen_pem = FALSE, ...)
set_api_key(app = c("google", "baidu", "gaode", "ipstack", "ipify",
"ipinfo"), key = NULL, gen_pem = FALSE, ...)
|
app |
character vector of the application name for the API, either 'google', 'baidu', 'gaode', 'ipstack', 'ipinfo' or 'ipify'. |
overide |
logical, whether flush the stored API key and call a GUI wizard to enter a new one. Default FALSE to enable reusing the keys. |
drop |
logical, whether coerce the result to a named vector. Default TRUE. If FALSE, you will get a named list instead. |
... |
other arguments. For instance,
|
key |
character vector or list, value(s) of the API key(s). You can directly assign corresponding values here. Default NULL (gui mode), indicating that a GUI wizard will be launched for you to enter the API key respectively. Generally, gui mode is more secure. |
gen_pem |
logical, whether generate .pem files in the |
If the encrpyted API key(s) have been previously stored in the package
hidden environment pkgenv$API_KEY
, the function will extract it after an
auto decryption. If not previously stored in pkgenv
, a GUI wizard
(inputChar
) will be launched for you to enter the key(s).
When you encounter an API error, please either
set overide=TRUE
to re-enter the key, or
directly call set_api_key
to do so. Each time you load aseshms,
you only need to set the API keys once.
invisible. You must assign it to an object.
Do not disclose the key to anyone as it may cause data leakage.
Yiying Wang, wangy@aetna.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
get_api_key('google', gui='WinGui')
get_api_key() # you will get all the api keys
# if the api keys have been written to .pem files
set_api_key('baidu', <YOUR BAIDU API KEY>, gen_pem=TRUE)
key <- decrypt_it(get_raw_pwd(pem='baidu'))
## End(Not run)
## Not run:
#' key <- <YOUR BAIDU API KEY> # not recommended: keys are exposed
setApiKey('baidu', key=key)
setApiKey('baidu', key=NULL) # recommended
# set multiple API keys
set_api_key(app=c("google", "baidu", "gaode", "ipstack", "ipinfo", "ipify"),
key=<THE CORRESPONDING KEY CHARACTER VECTOR>) # not recommended
set_api_key() # pop up a series of GUI windows to input all the API keys
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.