【问题标题】:Firebase emulator not authenticating suddenlyFirebase 模拟器没有突然进行身份验证
【发布时间】:2020-07-26 14:01:21
【问题描述】:

我今天打开了我们的firebase函数代码,像往常一样输入firebase serve,但是当我调用一个触及我们实时数据库的http函数时,我收到了这样的消息:

@firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"通过 \"credential\" 属性提供给 initializeApp() 的凭据实现未能获取有效的 Google带有以下错误的 OAuth2 访问令牌:\"Error fetching access token: invalid_grant (Bad Request)\"。可能有两个原因:(1) 您的服务器时间未正确同步或 (2) 您的证书密钥文件已被吊销. 要解决 (1),请重新同步服务器上的时间。要解决 (2),请确保您的密钥文件的密钥 ID 仍然存在于 https://console.firebase.google.com/iam-admin/serviceaccounts/project。如果没有,请在 @987654322 生成一个新的密钥文件@."}

与我上次(几周前?)能够运行它时没有任何变化,并且我的系统时间设置为时间和时区的自动。我跑了firebase logoutfirebase login,我正在使用无参数的admin.initializeApp();。有什么改变是我需要考虑的吗?

【问题讨论】:

  • 我已经更新了 firebase-cli,删除了 node_modules 和 npm-installed,尝试了 firebase emulators:start --only functions,database,但在尝试调用函数时都会出现相同的错误消息

标签: firebase google-cloud-functions firebase-cli


【解决方案1】:

我使用@https://firebase.google.com/docs/functions/local-emulator 找到的信息,通过点击底部的“创建密钥”来生成并设置密钥文件@https://console.cloud.google.com/iam-admin/serviceaccounts/details/##################?authuser=0&project=my-project-name

下载密钥文件后,我在我的项目目录中使用此命令行进行设置

set GOOGLE_APPLICATION_CREDENTIALS=path\to\key.json

完成后,我就可以在本地按预期运行我的功能了。

我爱你们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 2021-02-24
    • 1970-01-01
    • 2021-02-28
    • 2017-03-11
    • 2010-11-07
    相关资源
    最近更新 更多