【问题标题】:Google FCM firebase-admin initializeApp() error in K8S clusterK8S 集群中的 Google FCM firebase-admin initializeApp() 错误
【发布时间】:2021-12-11 04:25:55
【问题描述】:

我正在构建 NodeJs 服务器并尝试利用 FCM 进行推送通知。本地一切正常,但在 K8S 集群中我收到以下错误

FirebaseAppError: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Missing error payload".

errorInfo: {
    code: 'app/invalid-credential',
    message: 'Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Missing error payload".'
  },
  codePrefix: 'app'

我尝试在没有参数 admin.initializeApp() 的情况下初始化应用程序,将 env var 与路径 json 键保存在配置对象中,路径有效,文件存在,env 打印正常。 我试过这样const firebase = admin.initializeApp({ credential: admin.credential.applicationDefault(), });,这显然是同一件事。我尝试使用 json 证书显式传递凭证道具,例如 const firebase = initializeApp({ credential: admin.credential.cert(cert) }); 证书存在。我什至尝试将 firebase-admin 从 10 降级到 9。 节点 12 请帮忙

【问题讨论】:

    标签: node.js firebase kubernetes firebase-cloud-messaging


    【解决方案1】:

    我发现了一个问题。这是我的 K8S 集群的 DNS 设置。因此它无法正确访问外部世界(检查 pod 内的 /etc/resolv.conf) 必须像这样将 dns 设置添加到我的部署声明中

          containers:
            ...
          dnsPolicy: "None"
          dnsConfig:
            nameservers:
             - 10.96.0.10 // for inner services lookup
             - 8.8.8.8
            searches:
             - default.svc.cluster.local
             - svc.cluster.local
             - cluster.local
    

    【讨论】:

      猜你喜欢
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      • 2018-10-18
      • 2018-03-12
      相关资源
      最近更新 更多