0
votes

I know the issue of Missing or insufficient permissions has been asked before, but after weeks of Googling and searching I could not find an answer.

I've written a Firebase Cloud Function that triggers every time data is added to my Firestore database, it was all working fine, until one day it wasn't anymore, the function can read data from the database but it cannot write to it, it comes with the "Missing or insufficient permissions" error.

This is my code:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

const runtimeOpts = {
  timeoutSeconds: 30,
  memory: '2GB'
}

exports.titlePage = functions.region("europe-west2").runWith(runtimeOpts).firestore.document('savedCards/{userId}')
.onCreate(async (request, response) => {

    console.log(request.data().url)
    const title = "Hey!"

    return request.ref.set({
      title: title,
    }, {merge: true});

});

And my security rules, which should allow anyone to write to the database:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

Thank you!!

1
Where exactly are you seeing the "Missing or insufficient permissions" error?Renaud Tarnec
@RenaudTarnec This is the error I'm seeing: Error screenshotelrumo
Does the following SO answer help you: stackoverflow.com/questions/57306468/…Renaud Tarnec

1 Answers

0
votes

Security rules are not going to be an issue here because backend SDKs all bypass those rules completely. They only apply to client code.

Try redeploying your function, and if that doesn't help, contact Firebase support directly with the exact steps to take to reproduce this problem in your project.