Receiving this error when trying to read from my firebase firestore collection. It’s a public read only collection
E/flutter ( 2038): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.
Here’s my security rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /trainers {
allow read : if true;
}
}
}
I’ve also tried setting the rules like this
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /trainers {
allow read;
}
}
}
My query
firebaseDb.collection("trainers").get().then((value) => {
print(value)
});
main func
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
setSystemOverlay(getIsDarkMode());
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
3
Answers
I managed to find the solution, the rules syntax needs to be like so
Try changing your security rules to the following:
Not works, I’m use Flutter StreamBuilder and my rules in Firestore
But, before works, I don’t touch enythink only live to works, sorry my english is bad.