Firebase-tools: ADC 身份验证错误:此请求需要范围

创建于 2018-05-29  ·  46评论  ·  资料来源: firebase/firebase-tools

嗨,我正在尝试自动部署 firebase 功能。 当我运行类似“GOOGLE_APPLICATION_CREDENTIALS=火力使用--non-interactive --debug” 我有以下错误

版本信息

3.18.5

平台信息

容器节点:6.14-alpine

重现步骤

/usr/bin/docker run --rm -v /workspace:/workspace -e GOOGLE_APPLICATION_CREDENTIALS=node:6.14-alpine node_modules/firebase-tools/bin/firebase 使用--调试

预期行为

待认证

实际行为

[2018-05-29T15:57:32.507Z] > 命令需要范围:[“email”,“openid”,“https://www.googleapis.com/auth/cloudplatformprojects.readonly“,”https://www .googleapis.com/auth/firebase”]
[2018-05-29T15:57:32.507Z] > 尝试通过应用默认凭据进行身份验证
[2018-05-29T15:57:32.547Z]! 自动身份验证错误:此请求需要范围。
[2018-05-29T15:57:32.547Z] > 无法找到或自动检索凭据

你有什么建议吗?

最有用的评论

@mbleigh有更新吗? 确认目前 firebase CLI 无法使用服务帐户进行部署? 我们希望它用于 CI 工具。 所以 GOOGLE_APPLICATION_CREDENTIALS 支持不起作用?

所有46条评论

您好,所需的凭据不是 GOOGLE_APPLICATION_CREDENTIALS,因此该行实际上对您没有帮助。

您需要生成 CI 令牌,然后使用 --token 标志运行命令,请参阅https://github.com/firebase/firebase-tools#using -with-ci-systems 了解更多信息。

你好,
那么https://github.com/firebase/firebase-tools/pull/417呢?
似乎实现了 GOOGLE_APPLICATION_CREDENTIALS 并且 firebase-tools 使用 google-auto-auth 来获取它。

还是我错了?

我不会使用 CI 令牌,因为我想使用服务帐户而不是 Google 用户(GSuite 或 Cloud Identity 或其他任何内容)进行身份验证

谢谢

你好,
似乎图书馆调用了 firebase-public.firebaseio。 com:443并且具有 200 的 HTTP 返回码但响应为 0 字节

嗨,你说得对。 抱歉,我忘了那个 PR。 我对这个不是很熟悉。 迈克尔,你回到办公室后能看一下吗?

@laurenzlong @mbleigh
我发现为服务帐户许可配置“域范围权限”以进行身份​​验证。
但现在我有以下问题:

GOOGLE_APPLICATION_CREDENTIALS=<path_to_json> firebase deploy --only functions --non-interactive --project=<project_id> --debug

[2018-06-04T09:25:46.202Z] ----------------------------------------------------------------------
[2018-06-04T09:25:46.211Z] CLI Version:   3.18.5
[2018-06-04T09:25:46.212Z] Platform:      linux
[2018-06-04T09:25:46.212Z] Node Version:  v6.14.2
[2018-06-04T09:25:46.212Z] Time:          Mon Jun 04 2018 09:25:46 GMT+0000 (UTC)
[2018-06-04T09:25:46.213Z] ----------------------------------------------------------------------

[2018-06-04T09:25:46.238Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-06-04T09:25:46.238Z] > attempting to authenticate via app default credentials
[2018-06-04T09:25:46.445Z] xxxx.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xx
[2018-06-04T09:25:46.446Z] > retrieved access token via default credentials
[2018-06-04T09:25:46.449Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/<project_id>  

 Mon Jun 04 2018 09:25:46 GMT+0000 (UTC)
[2018-06-04T09:25:47.067Z] <<< HTTP RESPONSE 404 server=nginx, date=Mon, 04 Jun 2018 09:25:47 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff
[2018-06-04T09:25:47.069Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found.

服务帐户对项目具有编辑器权限,如果我使用 Google 身份(而不是 svc 帐户),则问题不存在

我发现了这个类似的问题(但他们使用令牌) https://github.com/firebase/firebase-tools/issues/744

谢谢

不,我错了。
如果我执行firebase use我再次:

[2018-06-04T14:39:38.660Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[2018-06-04T14:39:38.660Z] > attempting to authenticate via app default credentials
[2018-06-04T14:39:38.693Z] ! auto-auth error: Scopes are required for this request.
[2018-06-04T14:39:38.694Z] > no credentials could be found or automatically retrieved

即使分配了Owner角色的服务帐户尝试使用firebase CLI 工具执行任何操作,也会出现相同的行为:

$ export GOOGLE_APPLICATION_CREDENTIALS=account.json
$ firebase list --debug
[2018-06-05T12:15:17.340Z] ----------------------------------------------------------------------
[2018-06-05T12:15:17.343Z] Command:       /usr/local/bin/node /usr/local/bin/firebase list --debug
[2018-06-05T12:15:17.343Z] CLI Version:   3.18.5
[2018-06-05T12:15:17.343Z] Platform:      linux
[2018-06-05T12:15:17.343Z] Node Version:  v10.3.0
[2018-06-05T12:15:17.343Z] Time:          Tue Jun 05 2018 12:15:17 GMT+0000 (UTC)
[2018-06-05T12:15:17.343Z] ----------------------------------------------------------------------

[2018-06-05T12:15:17.347Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[2018-06-05T12:15:17.348Z] > attempting to authenticate via app default credentials
[2018-06-05T12:15:17.352Z] ! auto-auth error: Scopes are required for this request.
[2018-06-05T12:15:17.352Z] > no credentials could be found or automatically retrieved

Error: Command requires authentication, please run firebase login

一个小线索是访问令牌为空(我有同样的问题,我解码了 JWT)

它从它的形式暗示
xxxx.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

中间的 x 是数据负载,大小为 1 个字符,因此显然不是很满。

firebase-tools 使用 google-auto-auth 来获取令牌,所以我认为问题可能存在。

哎呀,新版本( 3.18.6 )似乎仍然没有将authScopes传递给autoAuth() 。 如果我在此行之前添加日志语句: https :
我得到authScopes: undefined

如果我添加

authScopes = [
  scopes.EMAIL,
  scopes.OPENID,
  scopes.CLOUD_PROJECTS_READONLY,
  scopes.FIREBASE_PLATFORM,
];

在该行之前,然后它继续获取访问令牌,但以PROJECT_NOT_FOUND失败

还有@tomlarkworthy ,那个 OAuth 令牌不是 JWT,所以它不应该包含中间部分。 如果您在https://developers.google.com/apis-explorer/#search/oauth2/oauth2/v2/oauth2.tokeninfo 中运行它,它将报告为"scope": "https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email",的有效令牌

谢谢! 好的所以当我得到项目未找到错误时。 当我解码令牌时,我只有一个范围“ https://www.googleapis.com/auth/cloud-platform ”。

一个“正常”的令牌(即,通过获取的一个之间的差值firebase login ):

{
 "issued_to": "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com",
 "audience": "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com",
 "user_id": "xxxyyy",
 "scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/plus.me",
 "expires_in": 3484,
 "email": "[email protected]",
 "verified_email": true,
 "access_type": "offline"
}

和一个从服务帐户 (SA) 生成的:

{
 "issued_to": "1160xxxx",
 "audience": "1160xxxx",
 "user_id": "1160xxxx",
 "scope": "https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email",
 "expires_in": 3563,
 "email": "[email protected]",
 "verified_email": true,
 "access_type": "offline"
}

所以看起来令牌没有发给正确的audienceuser_id ,这应该是来自https://github.com/firebase/firebase-tools/blob/376678fef91f71de5859f14d8374b2d8d2731980/库/api.js#L84

@tomlarkworthy仍然很奇怪,除非我明确添加了正确的范围,否则我的authScopeundefined 。 你在运行这个之前firebase logout吗?

好的,客户端 ID 是 oath2 客户端,它具有非常特定的域,可以在我们无法配置的情况下工作。 和/或需要本地主机上的用户交互。 所以在 CI 中很难获得授权。

我在一个函数上运行我的。 我没有和你一样的错误。 我找不到像原始海报那样的项目。

如果我从服务帐户中构建自己的令牌并将其与 --token 一起传递,我会得到:-

HTTP RESPONSE 401变化=X-Origin, Origin,Accept-Encoding, www-authenticate=Bearer realm=" https://accounts.google.com/ ", content-type=application/json; 字符集=UTF-8,日期=星期四,2018 年 6 月 7 日 00:16:43 GMT,过期=星期四,2018 年 6 月 7 日 00:16:43 GMT,cache-control=private,max-age=0,x-content- type-options=nosniff, x-frame-options=SAMEORIGIN, x-xss-protection=1; 模式=块,服务器=GSE,alt-svc=quic=“:443”; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-06-07T00:16:43.786Z] <<< HTTP RESPONSE BODY error=unauthorized_client, error_description=Unauthorized
[2018-06-07T00:16:43.791Z] > 命令需要范围:["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www .googleapis.com/auth/firebase"]
[2018-06-07T00:16:43.792Z] > 通过 --token 选项授权
[2018-06-07T00:16:43.792Z] > 使用范围刷新访问令牌:["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https:// /www.googleapis.com/auth/firebase"]
[2018-06-07T00:16:43.793Z] >>> HTTP 请求发布https://www.googleapis.com/oauth2/v3/token
{ refresh_token: 'ya29.c.XXXXXXXXXXXX',
client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
grant_type: 'refresh_token',
范围:'email openid https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase ' }

我认为这个誓言客户 ID 有碍观瞻?

@tomlarkworthy不一定很难 - 我现在正在用clientId测试配置。

我尝试使用自己的 oauth 客户端创建自定义项目并覆盖 firebase-tools client_id 和 secret_id。 然后对 oath Web 应用程序进行了授权,复制了令牌并使用它来调用 firebase-tools。 它的路径略有不同,并成功刷新了令牌,但无法获取项目列表。 我在令牌解码器中确认它具有 cloudplatformprojects 只读范围,因此它应该能够读取它们。

信息:标准错误:[2018-06-07T01:02:21.126Z] 环境覆盖:FIREBASE_CLIENT_ID、FIREBASE_CLIENT_SECRET
[2018-06-07T01:02:21.126Z] -------------------------------------- --------------------------------

信息:stderr: [2018-06-07T01:02:21.138Z] > 命令需要范围:["email","openid"," https://www.googleapis.com/auth/cloudplatformprojects.readonly "," https ://www.googleapis.com/auth/firebase "," https://www.googleapis.com/auth/cloud-platform "]

信息: stderr: [2018-06-07T01:02:21.138Z] > 通过 --token 选项授权
[2018-06-07T01:02:21.140Z] > 使用范围刷新访问令牌:["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https:// /www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-06-07T01:02:21.140Z] >>> HTTP 请求发布https://www.googleapis.com/oauth2/v3/token
{ refresh_token: 'ya29.XXX',
client_id: '278696186940-fbqtl733l62g4qj8aekr4i66cpo0k5c1.apps.googleusercontent.com',
client_secret: 'XXXX',
grant_type: 'refresh_token',
范围:'email openid https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform ' }
2018 年 6 月 6 日星期三 18:02:21 GMT-0700 (PDT)

信息:标准错误:[2018-06-07T01:02:21.318Z] <<< HTTP 响应 200 x-google-netmon-label=/bns/ph/borg/ph/bns/apiserving/prod_hightraffic_api_frontend.server/998, x -google-gfe-backend-request-info=eid=HYQYW5jODYyytgbB3JfoAg, cache-control=no-cache, no-store, max-age=0, must-revalidate, pragma=no-cache, expires=Mon, 01 Jan 1990格林威治标准时间 00:00:00,日期 = 2018 年 6 月 7 日星期四 01:02:21 GMT,变化 = X-起源,起源,接受编码,x-google-session-info = GgIYBiAB,内容类型 = 应用程序/json ; 字符集=UTF-8,x-content-type-options=nosniff,x-frame-options=SAMEORIGIN,x-xss-protection=1; mode=block, server=GSE, x-google-servertype=apiserving, x-google-gfe-request-trace=acsfoh11:443,phnm21-v6:9897,/bns/ph/borg/ph/bns/apiserving/prod_hightraffic_api_frontend .server/998,phnm21-v6:9897,acsfoh11:443, x-google-gslb-service=apiserving-hightraffic, x-google-backends=plbn61:9882,/bns/ph/borg/ph/bns/apiserving/ prod_hightraffic_api_frontend.server/998,phnm21-v6:9897,/bns/ph/borg/ph/bns/traffic-prod/shared-layer2-gfe/495,acsfoh11:443, x-google-dos-service-trace= main :identity-o-auth-2-service-migration , main:shared-layer2-gfe , x-google-service=identity-o-auth-2-service-migration,restricted-shared-layer2-grpc-aggregate, x -google-gfe-response-code-details-trace=response_code_set_by_backend,response_code_set_by_backend, x-google-gfe-response-body-transformations=gunzipped, x-google-shellfish-status=CA0gBEBG, alt-svc=quic=":443 "; ma=2592000; v="43,42,41,39,35", x-google-gfe-service-trace=identity-o-auth-2-service-migration,restricted-shared-layer2-grpc-aggregate, accept-ranges=无,连接=关闭

信息:标准错误:[2018-06-07T01:02:21.319Z] >>> HTTP 请求获取https://admin.firebase.com/v1/projects/docsite-go

2018 年 6 月 6 日星期三 18:02:21 GMT-0700 (PDT)

信息:stderr:[2018-06-07T01:02:21.652Z] <<< HTTP RESPONSE 404 server=nginx, date=Thu, 07 Jun 2018 01:02:21 GMT, content-type=application/json; 字符集=utf-8,内容长度=87,连接=关闭,x-内容类型选项=nosniff

info: stderr: [2018-06-07T01:02:21.652Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=未找到指定的项目。

@tomlarkworthy用自定义值覆盖 client_id 和 secret 将不起作用,因为 Firebase 当前使用与任何客户项目分开的预定义客户端(至少这是我的理解)。

此外, --token选项仅支持刷新令牌,如果您有服务帐户,则无法获得刷新令牌(再次,据我所知)。

如果可能,我们需要找到一种简单的方法来使用此客户端 ID 生成 SA 访问令牌。

可以采用替代路线并使用客户端 JWT 而不是 OAuth 令牌调用 Firebase API,如下所述: https :

google/google-auth-library-nodejsstephenplusplus/google-auto-auth内部使用,提供了一种更方便/安全的方法来做到这一点。

我不认为我们可以取得进展。

https://github.com/firebase/firebase-tools/issues/647#issuecomment -361926336 之前似乎已报告成功,但不确定是否已确认。 似乎有问题的 Firebase API (https://admin.firebase.com/v1/projects) 是private ,并且只接受为该客户端 ID 生成的令牌。

也许这应该作为功能请求提交 - 能够使用服务帐户进行部署将允许使用单个凭据(并与任何用户分离)来部署 Firebase 和 GCP 资源。

CLI 中的--token选项旨在传递刷新令牌,而不是访问令牌。 它是从firebase login:ci

我没有广泛测试服务帐户授权,但我怀疑admin.firebase.com后端可能会发生需要广泛许可的 IAM 检查。 我们可以进一步调查,但我不一定期望这里有超快的解决方案。

CLI 中的 --token 选项旨在传递刷新令牌

是的,如上所述理解。

使用 SA 密钥从 CI 环境进行部署会很棒。 刷新令牌与特定用户相关联,尚不清楚如何使用它来验证gcloud命令以管理其他 GCP 服务。 目前,我们必须提供两种类型的凭据(Firebase CLI 的管理员用户刷新令牌,以及gcloud的 SA 密钥)。

我能够使用为服务帐户生成的令牌FIREBASE_TOKEN='<token_here>' firebase deploy --only firestore,storage (我没有尝试过其他目标,它们可能工作)。

实际令牌是由Vault 的 GCP 机密引擎为服务帐户生成的,范围为“ https://www.googleapis.com/auth/cloud-platform ”。

我确认不可能使用 SA 密钥 + GOOGLE_APPLICATION_CREDENTIALS,使用最新的 firebase cli,任何命令退出:

root<strong i="6">@frontend</strong>:/usr/src/app$ firebase list

Error: HTTP Error: 404, The specified project was not found.

Having trouble? Try firebase list --help

@cpick很有趣,您知道 vault 如何为服务帐户生成 oauth 令牌吗?

@paolomainardi firebase list不适用于 SA 密钥,因为它取决于遗留项目列表实现。 但是,几乎所有其他内容都应该这样做(尽管您可能需要先启用一些 API)。 我建议尝试另一个命令并查看。

我们正在努力获得对GOOGLE_APPLICATION_CREDENTIALS全面支持,而不会跳过一堆障碍,因为我们认为它可以解锁一些很棒的用例。

@paolomainardi认为vault实现就在这里(这只是快速搜索其代码后的猜测)。

我也认为这与gcloud alpha iam service-accounts sign-jwt所做的相同(再次,有点受过教育的猜测)。

非常感谢@cpick ,我会及时

我简要地看了一下,作为一个测试,我试图通过一个服务帐户凭据和一个access_token强制进入requireAuth.js
试图至少看到一些工作。

似乎 cli 总是尝试联系https://admin.firebase.com/v1/projects/无论如何(您可以使用--debug标志来表达我的意思。如果我阅读了此问题中的先前评论,则可能是“遗留” “不适用于 svc 帐户的 api 端点”。

我确实用简单的GET调用测试了其他一些端点,它们似乎没问题:

参考


  • 我对requireAuth.js进行的硬编码修改只是为了测试,它会返回一个 svc_accounts 访问令牌,范围很广
function getServiceAccountClient() {
  const credFile = '/path/to/cert.json';
  const keys = require(credFile);
  let client = new JWT(
    keys.client_email,
    null,
    keys.private_key,
    ["email","openid","https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"],
  );
  return client;
};

function _autoAuth(options, authScopes) {
  return new Promise(function(resolve, reject) {
    var client = getServiceAccountClient();
    client.getAccessToken().then(res => {
      console.log(res);
     api.setAccessToken(res.token);
     resolve();

    }).catch(function (error) {
      console.error('Unable to recall targetClient access_token ' + error);
    });    

    /*
        logger.debug("> attempting to authenticate via app default credentials");
 ......

  • 通用客户端
const {JWT} = require('google-auth-library');

function getServiceAccountClient() {
    const credFile = '/path/to/cert.json';
    const keys = require(credFile);

    let client = new JWT(
      keys.client_email,
      null,
      keys.private_key,
      ["email","openid","https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"],
    );
    return client;
  };

  var client = getServiceAccountClient();
    let project_id = 'your_project';
    let url = 'https://admin.firebase.com/v1/projects/' + project_id
    //let url = "https://firestore.googleapis.com/v1beta1/projects/" + project_id + "/databases/(default)/indexes"
    //let url = "https://firebaserules.googleapis.com/v1/projects/" + project_id  + "/rulesets" 

    client.requestAsync({url}).then(resp => {
      console.log(resp.data);
    }).catch(function (error) {
      console.error('Unable to list buckets: ' + error);
    }); 

在对本要点中显示的requireAuth.js进行编辑后,我终于能够使用服务帐户部署到firestorestoragehosting
已经在那里的ADC..>

以下基本上是一个 hack 并且不完整,因为它不适用于functions部署。 上面 mbleigh 提到的“一流支持”的完整解决方案值得等待。


无论如何,我验证如下:

从与gcloud上下文中的 firebase 帐户开始

  1. 获取服务帐号私钥
$ gcloud iam service-accounts list
NAME                                EMAIL
App Engine default service account  [email protected]
firebase-adminsdk                   firebase-adminsdk-h2v8k@firebase-auth-sal.iam.gserviceaccount.com

gcloud iam service-accounts keys  create `pwd`/svc.json --iam-account=firebase-adminsdk-h2v8k@firebase-auth-sal.iam.gserviceaccount.com
  1. 在该项目上将服务帐户添加为OWNER

  2. 转到云控制台并启用一些 API:

https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=<your_project>

https://console.developers.google.com/apis/api/firebasehosting.googleapis.com/overview?project=<your_project>
  1. 删除本地凭据

对于gcloudfirebase

$ firebase logout
✔  Logged out from [email protected]

$ mv ~/.config/gcloud ~/.config/gcloud_backup
  1. 设置ADC env-var 并部署
export GOOGLE_APPLICATION_CREDENTIALS=`pwd`/svc.json

$ firebase deploy -P firebase-auth-sal --only firestore,hosting,storage 
{ token: 'ya29.c.EmJ8B....',  res: null }

=== Deploying to 'firebase-auth-sal'...

i  deploying storage, firestore, hosting
i  storage: checking storage.rules for compilation errors...
✔  storage: rules file storage.rules compiled successfully
i  firestore: checking firestore.rules for compilation errors...
i  firestore: reading indexes from firestore.indexes.json...
✔  firestore: rules file firestore.rules compiled successfully
i  storage: uploading rules storage.rules...
i  firestore: uploading rules firestore.rules...
✔  firestore: deployed indexes in firestore.indexes.json successfully
i  hosting[fir-auth-sal]: beginning deploy...
i  hosting[fir-auth-sal]: found 1 files in public
✔  hosting[fir-auth-sal]: file upload complete
✔  storage: released rules storage.rules to firebase.storage/firebase-auth-sal.appspot.com
✔  firestore: released rules firestore.rules to cloud.firestore
i  hosting[fir-auth-sal]: finalizing version...
✔  hosting[fir-auth-sal]: version finalized
i  hosting[fir-auth-sal]: releasing new version...
✔  hosting[fir-auth-sal]: release complete

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/firebase-auth-sal/overview
Hosting URL: https://fir-auth-sal.firebaseapp.com
  1. 验证部署

deployment_hosting

  1. 尝试functions部署

即使我尝试覆盖下面的启用检查, functions部署类型也不起作用(它在访问其他一些mobilesdk.googleapis.com端点时停止。也许 firebase 功能部署与client_id用于 firebase 函数或以某种方式需要 3LO ......但这都是猜想

$ firebase deploy -P firebase-auth-sal --only functions --debug

[2018-12-24T01:36:44.034Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/firebase-auth-sal?view=CONSUMER_VIEW  

[2018-12-24T01:36:44.034Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/firebase-auth-sal?view=CONSUMER_VIEW  

[2018-12-24T01:36:44.486Z] <<< HTTP RESPONSE 404 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Mon, 24 Dec 2018 01:36:44 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-12-24T01:36:44.486Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND

Error: HTTP Error: 404, Method not found.
[2018-12-24T01:36:44.495Z] Error Context: {
  "body": {
    "error": {
      "code": 404,
      "message": "Method not found.",
      "status": "NOT_FOUND"

内部错误参考:122552119

@tinaliang是否有关于此问题的任何更新? 我认为对身份验证的服务帐户支持应该是高度优先的。

暂时没有更新...

我最近几天的发现是,我不需要专门的 Firebase Cloud 函数,所以我可以使用 GCP Cloud 函数https://cloud.google.com/functions/ ,它按预期工作(部署是通过 gcloud CLI 完成的)但是,这不是真正的解决方法......但它可能对某人有帮助:)

由 #1175 复制

还有更新吗? 我尝试通过 Cloud Build 部署我的 Firebase 应用程序。 hosting等似乎可以正常工作和部署。 functions不会正确部署,我得到404 ,如上所述,在 IAM 中进行了适当的配置。 (服务帐户cloudbuild拥有“Firebase Admin”和“API Keys Admin”的权限。)这张票应该有高优先级🔥

还没有更新,但我们希望很快就能看到它。

@mbleigh有更新吗? 确认目前 firebase CLI 无法使用服务帐户进行部署? 我们希望它用于 CI 工具。 所以 GOOGLE_APPLICATION_CREDENTIALS 支持不起作用?

如前所述,并非所有firebase CLI 命令都适用于GOOGLE_APPLICATION_CREDENTIALS ,但应该有一个很好的数字。 将它设置为您的服务帐户凭据的路径应该是您需要做的所有事情(实际上,这就是test-hosting.sh脚本所做的,等等)。

使用firebase login:ci您应该能够在 CI 系统中使用令牌

GOOGLE_APPLICATION_CREDENTIALS的用法和功能正式化是我们的想法,但我们无法对它做出时间表。 谢谢你的耐心。

你能澄清一下 - 在这种情况下实例元数据 ADC 会起作用,还是只有GOOGLE_APPLICATION_CREDENTIALS

此线程上的任何人:如果您喜欢冒险,我很乐意让您尝试 #1463 上的分支,看看它是否可以让您使用服务帐户身份验证来完成您想要做的事情。 我认为我们可能已经解决了大部分问题,但我很想对这些问题进行一些外部测试。

@mbleigh firebase apps:list web在 Cloud Build 中有一半的时间会间歇性失败。 使用 debug 运行不会为我们提供有关失败原因的任何信息。 关于可能是什么情况的任何想法?

[2020-02-13T21:25:55.987Z] ----------------------------------------------------------------------
[2020-02-13T21:25:55.991Z] Command:       /usr/local/bin/node /workspace/node_modules/.bin/firebase apps:list web -j --project=projectName --debug
[2020-02-13T21:25:55.991Z] CLI Version:   7.12.1
[2020-02-13T21:25:55.991Z] Platform:      linux
[2020-02-13T21:25:55.991Z] Node Version:  v10.18.0
[2020-02-13T21:25:55.992Z] Time:          Thu Feb 13 2020 21:25:55 GMT+0000 (Coordinated Universal Time)
[2020-02-13T21:25:55.992Z] ----------------------------------------------------------------------

此外, @mbleigh firebase use projectName命令也会间歇性地失败,因为它无法从元数据服务器中提取正确的凭据:

[2020-02-13T21:49:41.050Z] ----------------------------------------------------------------------
[2020-02-13T21:49:41.055Z] Command:       /usr/bin/node /directory/node_modules/.bin/firebase --debug use projectName
[2020-02-13T21:49:41.056Z] CLI Version:   7.12.1
[2020-02-13T21:49:41.056Z] Platform:      linux
[2020-02-13T21:49:41.056Z] Node Version:  v10.16.3
[2020-02-13T21:49:41.056Z] Time:          Thu Feb 13 2020 21:49:41 GMT+0000 (Coordinated Universal Time)
[2020-02-13T21:49:41.056Z] ----------------------------------------------------------------------
[2020-02-13T21:49:41.057Z] 
[2020-02-13T21:49:41.073Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-02-13T21:49:41.073Z] > attempting to authenticate via app default credentials
[2020-02-13T21:49:41.669Z] TypeError: Cannot create property 'refresh_token' on string 'Not Found
'
    at /directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/oauth2client.js:208:28
    at /directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/computeclient.js:85:7
    at Request._callback (/directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/transporters.js:106:7)
    at Request.self.callback (/directory/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.EventEmitter.emit (domain.js:448:20)
    at Request.<anonymous> (/directory/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:198:13)
    at Request.EventEmitter.emit (domain.js:448:20)
    at IncomingMessage.<anonymous> (/directory/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:286:20)
    at IncomingMessage.emit (events.js:203:15)
    at IncomingMessage.EventEmitter.emit (domain.js:448:20)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

截至 20 年 2 月 10 日,在使用服务帐户时使用 cloudbuild 部署到 Firebase 托管时,我开始看到间歇性故障。 在此之前一段时间一直很好,现在似乎它经常失败。 我开始怀疑是否需要将一组新权限委派给服务帐户,以便它可以成功执行此操作。 这已经成为一个问题,因为我的大多数部署都失败了😞

下面是一个带有构建示例的屏幕截图,以及当它们突然开始失败时:

image

调试错误与上面的注释非常相似:

[2020-02-16T07:30:46.905Z] ----------------------------------------------------------------------
[2020-02-16T07:30:46.908Z] Command:       /usr/local/bin/node /home/node/.npm-global/bin/firebase deploy --only hosting -P project-production --debug
[2020-02-16T07:30:46.908Z] CLI Version:   7.8.1
[2020-02-16T07:30:46.908Z] Platform:      linux
[2020-02-16T07:30:46.909Z] Node Version:  v12.13.1
[2020-02-16T07:30:46.909Z] Time:          Sun Feb 16 2020 07:30:46 GMT+0000 (Coordinated Universal Time)
[2020-02-16T07:30:46.910Z] ----------------------------------------------------------------------
[2020-02-16T07:30:46.910Z] 
[2020-02-16T07:30:46.920Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-02-16T07:30:46.920Z] > attempting to authenticate via app default credentials
[2020-02-16T07:30:47.023Z] TypeError: Cannot create property 'refresh_token' on string 'Not Found
'
    at /home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/oauth2client.js:208:28
    at /home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/computeclient.js:85:7
    at Request._callback (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/transporters.js:106:7)
    at Request.self.callback (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
    at Request.emit (events.js:210:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at Request.<anonymous> (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:210:5)
    at Request.EventEmitter.emit (domain.js:475:20)
    at IncomingMessage.<anonymous> (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:299:28)
    at IncomingMessage.emit (events.js:215:7)
    at IncomingMessage.EventEmitter.emit (domain.js:475:20)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Error: An unexpected error has occurred.

这似乎与https://github.com/firebase/firebase-tools/issues/1970相关(即弃用旧的v1beta1实例元数据端点,旧的 gcloud Auth 仍在使用这些端点Firebase CLI 使用的库..)

此页面是否有帮助?
0 / 5 - 0 等级