我正在尝试在node.js中使用Firebase,但是每次重新启动服务器时,都会出现以下错误:
FIREBASE警告:提供的身份验证凭据无效。这通常表明您的FirebaseApp实例未正确初始化。确保您的apiKey和databaseURL与https://console.firebase.google.com/上为您的应用提供的值匹配,或者如果您使用的是服务帐户,请确保其被授权访问指定的databaseURL并且来自正确的项目。
以下是我的index.js:_
var express = require('express');
var router = express.Router();
var mongoose=require('mongoose');
var admin=mongoose.model('admin');
var firebase = require("firebase");
// Initialize the app with no authentication
firebase.initializeApp({
serviceAccount: {
projectId: "...",
clientEmail: "...",
privateKey: "-----BEGIN PRIVATE KEY-----...",
},
databaseURL: "..."
});
console.log("sfsaf")
// The app only has access to public data as defined in the Security Rules
var db = firebase.database();
var ref = db.ref("unitalk-b9145");
var messagesRef = ref.child("messages");
messagesRef.push({
name:"Rupali",
post:"Demo test of firebase"
});Run Code Online (Sandbox Code Playgroud)
虽然我已经检查了服务帐户和databaseURl的路径。.请帮助..