0

我得到一个错误:API error 7 (images: ACCESS_DENIED)我怎样才能把我的谷歌云应用程序引擎进入我火力地堡贮存桶

通常我会和我的谷歌App Engine服务相关联的火力地堡的应用程序,但由于公司的FireStore是不与App Engine兼容,我必须创建服务的单独实例。但是,现在我需要我的应用引擎映像服务能够引用Firebase云存储文件夹中的文件。我如何设置访问权限,是否需要创建在两种服务之间共享的某种IAM?我的应用程序引擎去功能指引的火力存储桶the-other-firebase-app

func photoHandler(w http.ResponseWriter, r *http.Request) { 

    c := appengine.NewContext(r) 
    v := r.URL.Query() 
    fileName := v.Get("file") 
    if (fileName == "") { 
     fmt.Fprint(w, "file name is required") 
    } else { 
     filename := "/gs/the-other-firebase-app.appspot.com/photos/" + fileName; 
     blobKey,err := blobstore.BlobKeyForFile(c, filename) 
     if (err == nil) { 
      url, urlErr := image.ServingURL(c, blobKey, nil) 
      if (urlErr == nil) { 
       fmt.Fprint(w, url) 
      } else { 
       fmt.Fprint(w, urlErr) 
      } 
     } else { 
      fmt.Fprint(w, "image does not exist") 
     } 
    } 
} 

回答

1

如果您的应用程序是一个标准的ENV一个它应该已经有一个服务帐户的

示例,请参阅Using service accounts

The App Engine application runs using the identity of the App Engine default service account. You can see this account on the IAM page in the Cloud Platform Console.

如果您的应用是柔性引擎,请参阅Service Account for the App Engine Flexible Environment

When you enable the Google App Engine flexible environment API, a specific service account is automatically created. You can view your project's service accounts in the IAM section of the Cloud Platform Console . The email for the App Engine flexible environment service account is service-[PROJECT-NUMBER]@gae-api-prod.google.com.iam.gserviceaccount.com , where [PROJECT-NUMBER] is the project number listed in the IAM settings .

在Firebase应用项目中,您需要添加GAE应用的服务帐户作为团队成员,并为其授予必要的权限。

正如在评论中提及:

Firebase Dasbhoard -> Project Settings Cog -> Users and permissions – MonkeyBonkey

潜在的利益也可能是Integrate with Google Cloud Platform

+0

添加项目成员的链接是一个谷歌的云仪表板,而不是Firebase仪表板 - 如何操作Firebase项目的权限 - 我没有在Firebase仪表板中看到任何项目成员添加。 – MonkeyBonkey

+0

哦,我现在看到它,我可以继续Firebase Dasbhoard - >项目设置Cog - >用户和权限 – MonkeyBonkey

0

我有一个非常类似的问题,但抛出的确切的错误信息是:

_"[email protected] does not have storage.objects.get access to storage_file_path_here>"_

我固定它得益于eltonnobrega建议在Github上:https://github.com/firebase/functions-samples/issues/299

这里有一个总结:

  1. 到达Google Cloud Console并选择您的存储桶所在的项目 - 您想要从您的服务器访问的存储桶副帐户。
  2. 转到存储选项卡
  3. 在浏览器选项卡上,您应该看到此项目中的存储桶。每个人都会有在右边(三个垂直圆点)
  4. 从这些选项结束行的选项图标,选择编辑区权限
  5. 从那里,你可以添加成员。添加您的服务帐户([email protected]),并给它的存储对象管理角色

enter image description here

相关问题