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

相關問題