skip to Main Content
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

These are my firestore rules. As you can see, I am allowing read/write access to everyone. However, when I run the app, I get an error "[cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation."

I don’t understand. Which part should I check?

2

Answers


  1. Chosen as BEST ANSWER

    I solved the problem. The cause was the problem of going back and forth between the local emulator and the actual firestore.

    After logging in from the Firebase emulator, I didn't log out. And because I tried to connect to the actual Firebase, an error occurred.

    if (FirebaseAuth.instance.currentUser != null) {
          await FirebaseAuth.instance.signOut();
        }
    

    I tried logging out with this code and it worked.


  2. Change Your rules like this

    rules_version = '2';
    service cloud.firestore {
    match /databases/{database}/documents {
     match /{document=**} {
      allow read, write: if request.auth != null;
      }
     }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search