Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 从在云运行中运行的水管工内部访问云存储_Google Cloud Platform_Google Cloud Run_Httr_Gargle_Googleauthr - Fatal编程技术网

Google cloud platform 从在云运行中运行的水管工内部访问云存储

Google cloud platform 从在云运行中运行的水管工内部访问云存储,google-cloud-platform,google-cloud-run,httr,gargle,googleauthr,Google Cloud Platform,Google Cloud Run,Httr,Gargle,Googleauthr,我在cloud run中运行了PlumberAPI,我想在同一个项目中访问google存储桶中的文件。API运行良好,但我无法通过身份验证。我试图使用googleAuthR和漱口库,但我做错了什么 这是我的api.R #* @get / function(){ text <- "Hello, this is from a cloud run function...." return ( text ) } #* @get /haveToken function(

我在cloud run中运行了PlumberAPI,我想在同一个项目中访问google存储桶中的文件。API运行良好,但我无法通过身份验证。我试图使用googleAuthR和漱口库,但我做错了什么

这是我的api.R

#* @get /
function(){
  text <- "Hello, this is from a cloud run function...."
  return ( text )
}

#* @get /haveToken
function(){
  require(googleAuthR)
  require(googleCloudStorageR)
  require(gargle)
  text <- paste0("Do I have a token: ",gar_has_token())
  #gcs_auth(token = token_fetch())
  gar_auth( gar_gce_auth_default()  )
  text <- paste0(text,"<br>Do I have a token: ",gar_has_token())
  return ( gcs_list_buckets(projectId = "<MYPROJECT>") )
}
#*@get/
函数(){

text使用
googleAuthR::gar_gce_auth()
从运行在谷歌云上的计算机获取令牌

您的错误是什么?401?您的存储桶的策略是什么?细粒度还是统一?简单错误:非交互式会话且未选择身份验证电子邮件。设置JSON服务电子邮件身份验证或在gar_auth中指定电子邮件(电邮:me@preauthenticated.com')>您有服务帐户密钥文件吗?如果有,您是否尝试在环境变量
GOOGLE\u APPLICATION\u CREDENTIALS
中添加文件的完整路径?当我在笔记本电脑上运行时,我可以这样做。将密钥文件放在docker映像中安全吗?当另一个开发人员签入github的密钥时,我们被烧死了一次(这很难看)如果使用
googleAuthR::gar\u gce\u auth()
进行身份验证,则身份验证库将使用元数据服务器
FROM gcr.io/gcer-public/googlecloudrunner:master
COPY api.R .
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=as.numeric(Sys.getenv('PORT')))"]
CMD ["api.R"]
docker build -t gcs_test1 .
docker image tag gcs_test1:latest gcr.io/<MYPROJECT>/gcscr:latest
gcloud run deploy gcs-test1 --image=gcr.io/<MYPROJECT>/gcscr:latest  --platform managed --allow-unauthenticated --service-account=gcs-sa@<MYPROJECT>.iam.gserviceaccount.com