Home > Net >  Firebase) It says FireStore doesn't have permission, but I don't understand
Firebase) It says FireStore doesn't have permission, but I don't understand

Time:11-29

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?

CodePudding user response:

Change Your rules like this

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
 match /{document=**} {
  allow read, write: if request.auth != null;
  }
 }
}

CodePudding user response:

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.

  • Related