问题
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:
- Download the secret key from the firebase console.
Save the downloaded .json file in the path "./your project path/functions".
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" });
- Deploy the function.
来源:https://stackoverflow.com/questions/57306468/how-to-fix-missing-or-insufficient-permissions-at-http2callstream