我正在主持一个
node.js
功能,我想在
服务器端
.我的服务帐户
json
文件看起来像:
{
"apiKey" : ""
"authDomain" : ""
"databaseURL" : ""
"projectId" : ""
"storageBucket" : ""
"messagingSenderId": ""
}
出于种种原因,我删除了这些字段。当我加载凭证并创建
admin
实例通过:
import * as admin from 'firebase-admin' ;
import * as functions from 'firebase-functions';
const accountKeyPath = path.join(__dirname, '../credentials/serviceAccountKey.json')
const accountKey = require(accountKeyPath);
const firebaseAdmin = admin.initializeApp( accountKey );
这个
firebaseAdmin
足以
crud
数据库。但是,它不能创建新用户,除非我声明:
const firebaseAdmin = admin.initializeApp({
credential: admin.credential.cert(accountKey)
, databaseURL: "..."
});
至少看起来是这样。当我运行此命令时,会出现以下错误:
throw new
error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
^
Error: Certificate object must contain a string "private_key" property.
这对我来说是无法解释的,因为我不知道如何获得服务帐户
json
具有
private_key
.我是不是每次运行服务器都要创建一个?