Firebase 工具:以服务帐户登录

Firebase tools: login as service account

我找不到代表服务帐户部署 firebase 项目(功能)的方法。

documentation page and also I found nothing related in their bug tracker.

上都没有说什么

如上所述,我执行了 运行 firebase login:ci 命令,但随后我需要自己登录 - 我想以服务帐户登录。

使用 gcloud 工具可以使用此功能,但是,如 docs

中所述

Cloud Functions written using the Firebase SDK for Cloud Functions can't be deployed using the gcloud command-line tool, and vice-versa.

firebaser 在这里

自从 Firebase version 7.1 CLI/tools 以来, 可以使用服务帐户进行身份验证。

另见迈克尔的回答:

上一个回答:

要使用 Firebase CLI/tools,您需要以实际用户身份登录。无法 运行 将 Firebase CLI 作为服务帐户。

虽然它被认为是一个有效且有趣的功能请求! this PR. As usual: no commits on if/when/how this may land. Keep an eye on the release notes 中正在进行一些可能有助于此功能的工作以获取最新更新。

您实际上可以使用有权访问 Firebase 角色的 Google 帐户(服务帐户或其他帐户)的刷新令牌,并将其设置为 FIREBASE_TOKEN 环境变量。

例如,我使用 Cloud Build(它有一个已经登录到 gcloud 的关联服务帐户),然后将 FIREBASE_TOKEN 设置为 gcloud auth application-default print-access-token.[=14 的输出=]

这个有效:

$> gcloud iam service-accounts keys create ./secrets.json --iam-account=<SERVICE_ACCOUNT_EMAIL>

$> export GOOGLE_APPLICATION_CREDENTIALS="./secrets.json"

$> firebase deploy --project <PROJECT_ID>