我正在尝试使用nodejs从云功能更新Firestore文档,但出现错误
错误日志:
Error: Missing or insufficient permissions.
at Http2CallStream.call.on (/srv/node_modules/@grpc/grpc-
js/build/src/client.js:101:45)
at emitOne (events.js:121:20)
at Http2CallStream.emit (events.js:211:7)
at process.nextTick (/srv/node_modules/@grpc/grpc-js/build/src/call-
stream.js:71:22)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
我试图更改Cloud Firestore安全规则,但未成功
答案 0 :(得分:1)
此问题已通过以下方式解决:
将下载的.json文件保存在路径“ ./your project path / functions”中。
将此代码添加到index.js的顶部:
var serviceAccount = require("./[downloaded file name].json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://[your project id].firebaseio.com"
});