How to fix “Missing or insufficient permissions at Http2CallStream”

冷暖自知 提交于 2020-01-25 09:13:08

问题


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

error Logs :

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)

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


回答1:


The problem was solved this way:

  1. Download the secret key from the firebase console.

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

  2. 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. Deploy the function.


来源:https://stackoverflow.com/questions/57306468/how-to-fix-missing-or-insufficient-permissions-at-http2callstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!