簡體   English   中英

使用服務帳戶憑據模式的 Firebase 分發 android 應用程序拒絕權限

[英]Permission denied with Firebase distribution android app using service account credentials mode

我正在嘗試從 Fabric 遷移到 Firebase,因為 Fabric 在 2020 年 3 月 31 日之后將不再可用。

我已經完成了第一步:將插件和依賴項添加到 gradle,添加分析 json 文件,甚至崩潰報告,一切似乎都是正確的,因為我可以在 Firebase 控制台中看到數據(分析和崩潰)。

但是,將應用程序分發系統從 Beta+Fastlane 遷移到 Firebase,我就沒有那么幸運了。 我正在嘗試“使用 Gradle 將 Android 應用程序分發給測試人員”選項。 我已經添加了插件和依賴項,並且添加得很好,因為我可以運行 gradle 任務./gradlew appDistributionUploadMyVariant

我正在從 Google Cloud Platform 控制台為名為firebase-adminsdk的用戶獲取serviceCredentialsFile (我認為這個名稱是由 Firebase 系統給出的)用於正確的項目。 The email of the user is something like this firebase-adminsdk-xxx@my_project.iam.gserviceaccount.com , and it is the same as I can see in Firebase console -> Settings -> Service accounts -> Firebase Admin SDK .

我已經下載了帶有憑據的 json 文件,並且 gradle 可以找到它,因為如果故意為文件輸入錯誤的路徑 URL,它會記錄Service credentials file does not exist 根據我上面提到的幾行,此文件的內容具有正確的client_emailproject_id值。

但我收到 403 錯誤。 如果我執行任務./gradlew appDistributionUploadMyVariant --info ,我會粘貼一些我得到的信息(我已經隱藏了一些私人信息):

Task ':app:appDistributionUploadMyVariant' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Found APK at /MyFolder/app/build/outputs/apk/qa/qaType/app-qa-qaType.apk.
Uploading APK to Firebase App Distribution...
Getting appId from output of google services plugin
-------------- REQUEST  --------------
POST https://oauth2.googleapis.com/token
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.28.0 (gzip)
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 808

curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.28.0 (gzip)' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://oauth2.googleapis.com/token' << $$$
Total: 808 bytes
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1N(...)
-------------- RESPONSE --------------
HTTP/1.1 200 OK
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Cache-Control: private
Server: scaffolding on HTTPServer2
X-Content-Type-Options: nosniff
Content-Encoding: gzip
Vary: Referer
Vary: X-Origin
Vary: Origin
X-XSS-Protection: 0
Date: Fri, 22 Nov 2019 14:47:29 GMT
Content-Type: application/json; charset=utf-8

Total: 207 bytes
{
  "access_token": "access_token_value",
  "expires_in": 3600,
  "token_type": "Bearer"
}
-------------- REQUEST  --------------
GET https://firebaseappdistribution.googleapis.com/v1alpha/apps/appId
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Firebase App Distro Client/1.2.0
x-app-distro-api-client-id: com.google.firebase
x-app-distro-api-client-type: gradle
x-app-distro-api-client-version: 1.2.0

curl -v --compressed -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: Firebase App Distro Client/1.2.0' -H 'x-app-distro-api-client-id: com.google.firebase' -H 'x-app-distro-api-client-type: gradle' -H 'x-app-distro-api-client-version: 1.2.0' -- 'https://firebaseappdistribution.googleapis.com/v1alpha/apps/appId'
-------------- RESPONSE --------------
HTTP/1.1 403 Forbidden
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
Cache-Control: private
Server: ESF
X-Content-Type-Options: nosniff
Content-Encoding: gzip
Vary: Referer
Vary: X-Origin
Vary: Origin
X-XSS-Protection: 0
Date: Fri, 22 Nov 2019 14:47:30 GMT
Content-Type: application/json; charset=UTF-8

Total: 126 bytes
{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
  }
}

:app:appDistributionUploadMyVariant (Thread[Daemon worker Thread 8,5,main]) completed. Took 1.552 secs.
AAPT2 aapt2-3.4.1-5326820-osx Daemon #0: shutdown

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:appDistributionUploadMyVariant'.
> App Distribution failed to fetch app information: [403] The caller does not have permission

我還嘗試從 gradle 文件中傳遞appId值,結果相同。

任何想法?

錯誤“[403] 調用者沒有權限。” 是由權限問題引起的。

你能試着按照這個來了解如何創建服務帳戶以及在哪里下載 json,看看它是否有效?

也歡迎您與firebase 支持聯系以獲取更多信息。 :)

請嘗試運行

firebase logout

然后再次登錄(或使用令牌)。

我遇到了同樣的問題,並且按照上面提到的所有其他步驟都沒有成功。 但是,當我使用調試標志運行firebase appdistribution:distribute --debug foo時,我注意到我仍然登錄到另一個 firebase 實例,這似乎導致了問題。

服務帳戶的角色是:“Firebase App Distribution Admin SDK 服務代理”:

管理員對 Firebase 應用程序分發的讀寫訪問權限 SDK

或作為個人權限

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM