如何解决"Http2CallStream上缺少或权限不足"的问题; [英] How to fix "Missing or insufficient permissions at Http2CallStream"

查看:99
本文介绍了如何解决"Http2CallStream上缺少或权限不足"的问题;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用nodejs从云功能更新Firestore文档,但出现错误

I'm trying to update firestore document from cloud function using nodejs, but getting error

错误日志:

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安全规则,但未成功

I tried to change the Cloud Firestore Security Rules, no success

推荐答案

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

The problem was solved this way:

  1. 从Firebase控制台下载密钥.

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

  1. Save the downloaded .json file in the path "./your project path/functions".

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

Add this code to the top of your index.js:

var serviceAccount = require("./[downloaded file name].json");

admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: "https://[your project id].firebaseio.com"
});

  1. 部署功能.

这篇关于如何解决"Http2CallStream上缺少或权限不足"的问题;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆