firestore: PERMISSION_DENIED: Missing or insufficient permissions

S Rekhu picture S Rekhu · Oct 5, 2017 · Viewed 163k times · Source

I am getting the Error

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.

for the below code on else statement

db.collection("users")
    .get()
    .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
             if (task.isSuccessful()) {
                 for (DocumentSnapshot document : task.getResult()) {
                     s(document.getId() + " => " + document.getData());
                 }
             } else {
                 s("Error getting documents."+ task.getException());
             }
         }
     });

Answer

Luvnish Monga picture Luvnish Monga · Oct 25, 2017

It simply works for me.

Go in Database -> Rules ->

Change allow read, write: if false; to true;

Note: This completely turns off security for the database!

Making it world writable without authentication!!! This is NOT a solution to recommend for a production environment. Only use this for testing purposes.