gpt4 book ai didi

node.js - Angular 通用 |火力管理|代码 : 'app/invalid-credential' |socket hang up on

转载 作者:太空狗 更新时间:2023-10-29 17:15:01 26 4
gpt4 key购买 nike

import * as admin from 'firebase-admin';
var serviceAccount = require('./keys/keyfile.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://test.firebaseio.com"
});

var registrationToken = "--some-key--";

var payload = {
notification: {
title: "$GOOG up 1.43% on the day",
body: "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day."
},
data: {
stock: "GOOG",
open: "829.62",
close: "635.67"
}
};


function panelMessage(){
admin.messaging().sendToDevice(registrationToken, payload)
.then(function(response) {
// See the MessagingDevicesResponse reference documentation for
// the contents of response.
console.log("Successfully sent message:", response);
})
.catch(function(error) {
// console.log(serviceAccount);
var date = new Date();
console.log(date.toString());
console.log("Error sending message:", error);
});
}

我通过 node 运行这段代码并且它可以工作但是当我将它添加到 angular-universal 中时

server.ts

文件..它给出以下错误..

Error sending message: { Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "socket hang up". at FirebaseAppError.Error (native) at FirebaseAppError.FirebaseError [as constructor] (D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\utils\error.js:39:28) at new FirebaseAppError (D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\utils\error.js:84:23) at D:\angular2MH\firebase - panel\panel\node_modules\firebase-admin\lib\firebase-app.js:119:23 at ZoneDelegate.invoke (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:232:26) at Zone.run (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:114:43) at D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:502:57 at ZoneDelegate.invokeTask (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:265:35) at Zone.runTask (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:154:47) at drainMicroTaskQueue (D:\angular2MH\firebase - panel\panel\node_modules\zone.js\dist\zone-node.js:401:35)
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: "socket hang up".' } }

我检查了时间(在许多可能是问题的地方阅读)并且它们都已同步..谁能帮我解决这个问题?我正在使用这个存储库 repository

最佳答案

来自 Firebase 支持,Angular-Universal 不是我们官方支持的库。因此无法提供 OAuth。

为了解决这个问题,我为 firebase 创建了另一个服务器,并从通用服务器进行了 api 调用。它现在工作正常。

关于node.js - Angular 通用 |火力管理|代码 : 'app/invalid-credential' |socket hang up on,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45583903/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com