如何修复“ Http2CallStream上缺少或权限不足”

时间:2019-08-01 09:58:39

标签: android firebase google-cloud-functions

我正在尝试使用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安全规则,但未成功

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

此问题已通过以下方式解决:

  1. 从firebase控制台下载密钥。

enter image description here

  1. 将下载的.json文件保存在路径“ ./your project path / functions”中。

  2. 将此代码添加到index.js的顶部:

    var serviceAccount = require("./[downloaded file name].json");
    
    admin.initializeApp({
        credential: admin.credential.cert(serviceAccount),
        databaseURL: "https://[your project id].firebaseio.com"
    });
    

enter image description here

  1. 部署功能。