Я пытаюсь использовать Firebase в Node.js, но каждый раз, когда я перезапустить сервер я получаю следующее сообщение об ошибке:FIREBASE ВНИМАНИЕ: При условии, учетные данные аутентификации являются недействительными
FIREBASE WARNING: Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your apiKey and databaseURL match the values provided for your app at https://console.firebase.google.com/ , or if you're using a service account, make sure it's authorized to access the specified databaseURL and is from the correct project.
Ниже мои 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({
\t 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
\t \t \t var db = firebase.database();
\t \t \t var ref = db.ref("unitalk-b9145");
\t \t \t var messagesRef = ref.child("messages");
\t \t \t
\t \t \t messagesRef.push({
\t \t \t \t name:"Rupali",
\t \t \t \t post:"Demo test of firebase"
\t \t \t });
Хотя я проверил путь сервис-счета и DatabaseURL .. P Помощь в аренде.
@ Халил-я имею включить «firabase-администратора »и обновить с помощью следующего кода. ** admin.initializeApp ({ \t удостоверение: admin.credential.cert ({ ProjectID: "unitalk-b9145", clientEmail: «[email protected]ком», PrivateKey: "----- BEGIN PRIVATE ---" }), DatabaseURL: "https://unitalk-b9145.firsebaseio.com/" }); ** – Rupali
Но дает следующее error- Не удается прочитать свойство «cert» undefined – Rupali
Я уже упомянул выше упомянутые выше 4 точки и обновил следующий код: var firebase = require («firebase»); var admin = require («firebase-admin») ; вар ServiceAccount = требуется ("serviceAccountKey.json"); admin.initializeApp ({ удостоверение: admin.credential.cert (ServiceAccount), DatabaseURL: «<БАЗА ДАННЫХ _NAME> .firebaseio.com/" }); – Rupali