FirebaseException ([cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.)

Viewed 2437

Exception has occurred. FirebaseException ([cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.)

Code:

  Future<Users> bringUser(id) async {
    DocumentSnapshot doc =
        await _firestore.collection("kullanicilar").doc(id).get();
    if (doc.exists) {
      Users users = Users.dokumandanUret(doc);
      return users;
    }
    return null;
  }

Firebase:

{
  "rules": {
    ".read": true, 
    ".write": true  
  }
}
1 Answers

You are mixing up security rules for the Realtime Database and for Firestore, which are two different NoSQL database services offered by Firebase.

Rules you show in your question are for the Realtime Database but in your Flutter code you query Firestore.

You need to set your rules on the Firestore part of the console.

They will look like:

service cloud.firestore {
  match /databases/{database}/documents {

    // Match any document in the 'cities' collection
    match /cities/{city} {
      allow read: if <condition>;
      allow write: if <condition>;
    }
  }
}

(example from the doc)

Related