Flutter Firestore permissions denied
4,818
in my case, Its all because of Firebase Database rules configuration. Changed below rules for my testing and its started working. (not recommended)
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Before release set proper permission to access your database.
Author by
Shahzad Akram
Updated on December 07, 2022Comments
-
Shahzad Akram over 1 year
I have public permissions for my Flutter Android App.
service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write; } } }
But when I tries to query data like this:
class MyHome extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Firestore App"), centerTitle: true, ), body: StreamBuilder( stream: Firestore.instance.collection("mydata").snapshots(), builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { if (!snapshot.hasData) return CircularProgressIndicator(); return FirestoreListview(documents: snapshot.data.documents); }, ), ); } } class FirestoreListview extends StatelessWidget { final List<DocumentSnapshot> documents; FirestoreListview({this.documents}); @override Widget build(BuildContext context) { return ListView.builder( itemCount: documents.length, itemExtent: 90.0, itemBuilder: (BuildContext context, int index){ String name = documents[index].data["title"].toString(); return Text(name); }, ); } }
I Get this..
W/Firestore(12477): (0.6.6-dev) [Firestore]: Listen for Query(flutter_data) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null} I/System.out(12477): com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
I tried to recreate Flutter project and Firebase App but still getting same issue. With same settings I have a working Android native App project but for flutter its not working. I have been trying since last 5 hours but I am unable to figure it out that what actual problem is?
-
dazza5000 over 5 yearsPlease put the query you trying to execute
-
Shahzad Akram over 5 yearsPlease check , I have updated my question..
-
dazza5000 over 5 yearsDo you have a collection named myData?
-