【问题标题】:Google Firebase Admin SDK Service Account Expired?Google Firebase Admin SDK 服务帐号已过期?
【发布时间】:2018-10-30 22:24:44
【问题描述】:

我正在使用 google firebase admin sdk 并按照说明进行设置。我通过 FCM 发送消息和通知,这没有问题,但最近我注意到我们的指标显示没有通知发送到客户端设备。

查看了 Node.js 输出并看到了:

errorInfo:
   { code: 'messaging/invalid-apns-credentials',
     message: 'Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.' },
  codePrefix: 'messaging' }

请记住,我最初使用的凭据文件正在运行,并且环境中没有任何变化。

查看文档,除了提供 firebase admin sdk 要求开始的 json 文件之外,没有任何关于令牌过期或处理任何类型的身份验证的内容:

var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://my-app-id.firebaseio.com"
});

如果我登录到 Firebase 控制台并检查服务帐户,我可以看到它,我唯一的选择是生成一个新的私钥(蓝色大按钮)。

我应该做些什么来让凭据保持有效吗?更新代币什么的? FCM 设置文档中没有任何地方提到这一点,并且似乎暗示如果您使用官方的 firebase admin sdk,则不需要任何这种性质。这是我遵循的指南:https://firebase.google.com/docs/admin/setup

如果我需要添加一些额外的代码来捕捉证书过期和续订的时间,任何人都可以权衡一下吗?

谢谢!

【问题讨论】:

  • 不要认为这是您在服务器上设置 Firebase 的问题,而是您如何在 iOS 应用中设置 Firebase:A message targeted to an iOS device could not be sent because the required APNs SSL certificate was not uploaded or has expired. Check the validity of your development and production certificates.
  • @francisco mateo 这不是我看到的错误,我同时拥有 iOS 和 android 设备,但都没有收到任何通知。完全不知道你写的东西和这个有什么关系。
  • 我看到了同样的情况,我在errorInfo 中看到错误代码messaging/invalid-apns-credentials,可以追溯到此处的文档:firebase.google.com/docs/cloud-messaging/admin/errors 这与@FranciscoMateo 提到的错误有关以上。

标签: firebase firebase-cloud-messaging firebase-admin


【解决方案1】:

如果为相同 AppID 创建的新推送证书包含现有应用程序的捆绑 ID 和推送证书仅在 Firebase 中使用,那么您的应用程序的旧版本应继续使用新证书接收推送通知,无论您使用哪个证书

每当您更新您的 APNS 证书时,应用程序的所有版本 必须推送通知将再次收到通知。有 无需为此更新应用程序。

【讨论】:

    【解决方案2】:

    查看errorInfocode 键我注意到它说:messaging/invalid-apns-credentials,每个errorInfocode 的更多信息可以在这里找到:https://firebase.google.com/docs/cloud-messaging/admin/errors

    这个具体的errorCode 说:

    messaging/invalid-apns-credentials - 无法发送针对 iOS 设备的消息,因为所需的 APNs SSL 证书未上传或已过期。检查您的开发和生产证书的有效性。

    就我个人而言,我的生产 APNs 证书存在问题,并且能够通过 developer.apple.com 重新生成新证书来解决它

    要回答您最初的问题,APNs 证书每年都会过期,因此您需要每年重新生成并重新上传它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-20
      • 2017-07-01
      • 2019-01-15
      • 2021-09-05
      • 1970-01-01
      • 2020-05-21
      • 1970-01-01
      相关资源
      最近更新 更多