Firebase Cloud Functions Firestore Trigger produces: Error: 7 PERMISSION_DENIED: Missing or insufficient permissions

后端 未结 6 598
囚心锁ツ
囚心锁ツ 2020-12-29 13:48

I\'m trying to use a Firebase Cloud Function to update a document within my Firestore database, when one of my documents has been updated using a trigger. The trigger is cal

6条回答
  •  旧巷少年郎
    2020-12-29 14:09

    My solution was setting up the serviceAccount, check the following code snippet:

    var admin = require("firebase-admin");
    
    var serviceAccount = require("path/to/serviceAccountKey.json");
    
    admin.initializeApp({
      credential: admin.credential.cert(serviceAccount),
      databaseURL: "https://your-database-url.firebaseio.com"
    });
    

    You can generate the serviceAccountKey on: Firebase dashboard -> Project Settings -> Service Accounts tab

    Hope it helps!

提交回复
热议问题