R 永久保存googleway API密钥
有没有办法将API密钥永久保存到我的R配置文件或环境中,这样我就不必每次会话都使用R 永久保存googleway API密钥,r,googleway,R,Googleway,有没有办法将API密钥永久保存到我的R配置文件或环境中,这样我就不必每次会话都使用set\u key()?我不喜欢在我的代码中保存密钥,因为它位于github上。您可以将它放在第一个功能中,该功能位于Rprofile.site文件中 我不确定你在哪个平台上,但这应该可以 rfile <- list.files(path = Sys.getenv("R_HOME"), recursive = TRUE, full.names = TRUE, patt
set\u key()?我不喜欢在我的代码中保存密钥,因为它位于github上。您可以将它放在第一个功能中,该功能位于Rprofile.site
文件中
我不确定你在哪个平台上,但这应该可以
rfile <- list.files(path = Sys.getenv("R_HOME"), recursive = TRUE,
full.names = TRUE, pattern = "Rprofile.site")
file.edit(rfile)
保存文件并重新启动R
编辑
如果您的api密钥是一个令牌
对象,如oauth,只需保存到一个文件中,读入并分配给google\u api\u密钥
值。例如:
.First <- function(){
# Your oauth api key read in from file
google_api_key <- readRDS("~/.hide_google_token.rds")
# Use assign to explicitly set the environment in which to populate the key
assign("google_oauth_token", google_api_key, envir = .GlobalEnv)
}
.First您可以将其放入First
函数中,该函数位于Rprofile.site
文件中
我不确定你在哪个平台上,但这应该可以
rfile <- list.files(path = Sys.getenv("R_HOME"), recursive = TRUE,
full.names = TRUE, pattern = "Rprofile.site")
file.edit(rfile)
保存文件并重新启动R
编辑
如果您的api密钥是一个令牌
对象,如oauth,只需保存到一个文件中,读入并分配给google\u api\u密钥
值。例如:
.First <- function(){
# Your oauth api key read in from file
google_api_key <- readRDS("~/.hide_google_token.rds")
# Use assign to explicitly set the environment in which to populate the key
assign("google_oauth_token", google_api_key, envir = .GlobalEnv)
}
。首先