angular度通用| firebase-admin | 代码:'app / invalid-credential'| socket挂断

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); }); } 

我运行这个代码通过节点,它的工作,但是当我把它添加到angular度通用

server.ts

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

发送消息时出错:{Error:通过“凭证”属性向initializeApp()提供的凭证实现无法获取有效的Google OAuth2访问令牌,并出现以下错误:“套接字挂断”。 FirebaseAppError.Error(native)在FirebaseAppError.FirebaseError [作为构造函数](D:\ angular2MH \ firebase – panel \ panel \ node_modules \ firebase-admin \ lib \ utils \ error.js:39:28) :\ angular2MH \ firebase-panel \ panel \ node_modules \ firebase-admin \ lib \ utils \ error.js:84:23)在D:\ angular2MH \ firebase – panel \ panel \ node_modules \ firebase-admin \ lib \ firebase-在Zone.run(D:\ angular2MH \ firebase – panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js:232:26)处的Zone.run(D:\ angular2MH \ firebase – panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js:114:43)在D:\ angular2MH \ firebase – panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js (D:\ angular2MH \ firebase – panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js:265:35)在ZoneDelegate.invokeTask(D:\ angular2MH \ firebase- drainMicroTaskQueue(D:\ angular2MH \ firebase – panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js:\ panel \ panel \ node_modules \ zone.js \ dist \ zone-node.js:154:47) 401:35)
errorInfo:{code:'app / invalid-credential',message:'通过“credential”属性为initializeApp()提供的凭据实现无法获取有效的Google OAuth2访问令牌,出现以下错误:“socket hang up”。 }}

我检查了时间(阅读在很多地方,可能是问题),他们都同步..任何人都可以帮我解决这个问题? 我正在使用这个存储库

从Firebase-Support,Angular-Universal不是我们正式支持的图书馆。 所以不能提供OAuth。

为了解决这个问题,我做了另外一台服务器,用于firebase,并通过通用服务器进行api调用。 现在工作很好。