【问题标题】:Gcloud auth interfering with firebase credentialsGcloud auth 干扰 Firebase 凭据
【发布时间】:2020-04-02 23:43:34
【问题描述】:

我遇到了 gcloud 和 firebase 干扰问题。我有一个需要 gcloud auth 的项目——但是我开始了一个与我的 gcloud 项目分开的新 firebase 项目。我的 firebase 项目应该使用我的 firebase 身份验证 - 相反我收到以下错误:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
>      at GoogleAuth.getApplicationDefaultAsync (/Users/project/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)
>      at processTicksAndRejections (internal/process/task_queues.js:97:5)
>      at async GoogleAuth.getClient (/Users/project/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)
>      at async GrpcClient._getCredentials (/Users/project/functions/node_modules/google-gax/build/src/grpc.js:92:24)
>      at async GrpcClient.createStub (/Users/project/functions/node_modules/google-gax/build/src/grpc.js:213:23)

如果我确实通过gcloud auth login 登录我的帐户,然后将GOOGLE_APPLICATION_CREDENTIALS 替换为.bash_project — 我没有收到上述错误。我确实收到以下警告:

Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to /Users/.config/gcloud/legacy_credentials/xxx/xxx.json. Non-emulated services will access production using these credentials. Be careful!

据我了解,firebase 不需要您设置 gcloud,应该使用firebase login 提供的凭据,我不知道如何将这两者分开。我宁愿不必每次需要切换项目时都更改GOOGLE_APPLICATION_CREDENTIALS,也不想收到我一直收到的警告。

【问题讨论】:

    标签: firebase google-cloud-platform gcloud firebase-cli


    【解决方案1】:

    我认为您无法以某种方式解决此问题。不过,我已经能够为您的方案想出四种不同的解决方法,但我不确定它们是否符合您的需求。它们按方便的程度排序:

    • 授予两个帐户中的任何一个对另一个项目的权限并仅使用该帐户。这是可行的,因为您只需要一个帐户,并且您必须更改环境变量。
    • 在其中一个项目中,从另一个环境变量而不是 GOOGLE_APPLICATION_CREDENTIALS 检索凭据。我不确定这是否适合您,因为我不知道您在哪里使用它,但根据具体情况,它可能适合您。
    • 创建一个简单的脚本,只更改环境变量的值并在更改项目时运行它。这并不理想,也是您要避免的,但比手动更改值更容易。
    • 在您的计算机上使用两个不同的用户,每个用户在环境变量中存储不同的凭据。这并不复杂,但您在使用一个或另一个项目时必须更改用户,这意味着与之前的提案相同的负面方面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-04
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 2012-07-17
      • 2019-06-17
      • 2015-02-12
      相关资源
      最近更新 更多