Getting 'firestore/permission-denied' while integrating firestore in React native mobile app
Solution 1
If this error occurs when you run addTodo()
it means that the user doesn't have permission to write to the todos
collection. Access to Firestore data is controlled through its server-side security rules.
To simply allow anyone to write to todos
use a rule such as this:
service cloud.firestore {
match /databases/{database}/documents {
match /todos/{document=**} {
allow read, write: if true;
}
}
}
But I highly recommend you read the documentation so that you can write more secure rules that match the needs of your app.
Solution 2
In firestore, if you got any permission denied.This because firestore security rules.
In this case , Goto your database rules section and change if false into if true
allow read, write: if true;
Afsara
Updated on July 23, 2022Comments
-
Afsara almost 2 years
I'm trying to firestore documents through react native app, but facing the following issue
Here is the code
constructor() { super(); this.ref = firebase.firestore().collection('todos'); }
and we are triggering button click
addTodo() { this.ref.add({ title: this.state.textInput, complete: false, }); }
we are facing this issue
Error: Firestore: The caller does not have permission to execute the specified operation. (firestore/permission-denied). Error: Firestore: The caller does not have permission to execute the specified operation. (firestore/permission-denied).