firestore: PERMISSION_DENIED: Missing or insufficient permissions











up vote
17
down vote

favorite
5












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());
}
}
});









share|improve this question
























  • Is the user logged in?
    – Suhayl SH
    Oct 5 '17 at 16:10






  • 2




    Have you set the rules under Security Tab in Firebase Console?
    – Suhayl SH
    Oct 5 '17 at 16:11






  • 1




    My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
    – S Rekhu
    Oct 5 '17 at 16:31










  • thanks @SuhaylSH
    – S Rekhu
    Oct 5 '17 at 16:32










  • check stackoverflow.com/a/46636036/1028256
    – Mixaz
    Oct 23 '17 at 21:06















up vote
17
down vote

favorite
5












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());
}
}
});









share|improve this question
























  • Is the user logged in?
    – Suhayl SH
    Oct 5 '17 at 16:10






  • 2




    Have you set the rules under Security Tab in Firebase Console?
    – Suhayl SH
    Oct 5 '17 at 16:11






  • 1




    My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
    – S Rekhu
    Oct 5 '17 at 16:31










  • thanks @SuhaylSH
    – S Rekhu
    Oct 5 '17 at 16:32










  • check stackoverflow.com/a/46636036/1028256
    – Mixaz
    Oct 23 '17 at 21:06













up vote
17
down vote

favorite
5









up vote
17
down vote

favorite
5






5





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());
}
}
});









share|improve this question















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());
}
}
});






android firebase google-cloud-firestore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 25 '17 at 7:42









ruddra

7,70832546




7,70832546










asked Oct 5 '17 at 16:03









S Rekhu

108119




108119












  • Is the user logged in?
    – Suhayl SH
    Oct 5 '17 at 16:10






  • 2




    Have you set the rules under Security Tab in Firebase Console?
    – Suhayl SH
    Oct 5 '17 at 16:11






  • 1




    My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
    – S Rekhu
    Oct 5 '17 at 16:31










  • thanks @SuhaylSH
    – S Rekhu
    Oct 5 '17 at 16:32










  • check stackoverflow.com/a/46636036/1028256
    – Mixaz
    Oct 23 '17 at 21:06


















  • Is the user logged in?
    – Suhayl SH
    Oct 5 '17 at 16:10






  • 2




    Have you set the rules under Security Tab in Firebase Console?
    – Suhayl SH
    Oct 5 '17 at 16:11






  • 1




    My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
    – S Rekhu
    Oct 5 '17 at 16:31










  • thanks @SuhaylSH
    – S Rekhu
    Oct 5 '17 at 16:32










  • check stackoverflow.com/a/46636036/1028256
    – Mixaz
    Oct 23 '17 at 21:06
















Is the user logged in?
– Suhayl SH
Oct 5 '17 at 16:10




Is the user logged in?
– Suhayl SH
Oct 5 '17 at 16:10




2




2




Have you set the rules under Security Tab in Firebase Console?
– Suhayl SH
Oct 5 '17 at 16:11




Have you set the rules under Security Tab in Firebase Console?
– Suhayl SH
Oct 5 '17 at 16:11




1




1




My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
– S Rekhu
Oct 5 '17 at 16:31




My mistake, I didn't see the drop box for the cloud firestore. I was checking in realtime database only.
– S Rekhu
Oct 5 '17 at 16:31












thanks @SuhaylSH
– S Rekhu
Oct 5 '17 at 16:32




thanks @SuhaylSH
– S Rekhu
Oct 5 '17 at 16:32












check stackoverflow.com/a/46636036/1028256
– Mixaz
Oct 23 '17 at 21:06




check stackoverflow.com/a/46636036/1028256
– Mixaz
Oct 23 '17 at 21:06












4 Answers
4






active

oldest

votes

















up vote
40
down vote



accepted










It simply works for me.



Go in Database ->
Rules ->



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






share|improve this answer























  • Never knew there was something like this.. :) Thanks a lot
    – User-8017771
    Jun 12 at 6:19






  • 4




    note it allows everybody to read,write your database without any authorization.
    – saigopi
    Sep 12 at 11:26










  • This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
    – Duncan Luk
    Oct 30 at 15:21


















up vote
2
down vote













make sure your DB is not empty nor your query is for collection whom not exist






share|improve this answer




























    up vote
    2
    down vote













    Go in Database -> Rules ->
    and do this



    service cloud.firestore {
    match /databases/{database}/documents {
    match /{document=**} {
    allow read, write;
    }
    }
    }





    share|improve this answer

















    • 1




      Danger: this gives anyone read and write access to all of your databases
      – Salami
      Oct 9 at 10:09


















    up vote
    -1
    down vote













    Additionally, you may get this error if the collection reference from your code does not match the collection name on firebase.



    For example the collection name on firebase is users, but your referencing it with db.collection("Users") or db.collection("user")



    It is case sensitive as well.



    Hope this helps someone






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46590155%2ffirestore-permission-denied-missing-or-insufficient-permissions%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      40
      down vote



      accepted










      It simply works for me.



      Go in Database ->
      Rules ->



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






      share|improve this answer























      • Never knew there was something like this.. :) Thanks a lot
        – User-8017771
        Jun 12 at 6:19






      • 4




        note it allows everybody to read,write your database without any authorization.
        – saigopi
        Sep 12 at 11:26










      • This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
        – Duncan Luk
        Oct 30 at 15:21















      up vote
      40
      down vote



      accepted










      It simply works for me.



      Go in Database ->
      Rules ->



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






      share|improve this answer























      • Never knew there was something like this.. :) Thanks a lot
        – User-8017771
        Jun 12 at 6:19






      • 4




        note it allows everybody to read,write your database without any authorization.
        – saigopi
        Sep 12 at 11:26










      • This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
        – Duncan Luk
        Oct 30 at 15:21













      up vote
      40
      down vote



      accepted







      up vote
      40
      down vote



      accepted






      It simply works for me.



      Go in Database ->
      Rules ->



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






      share|improve this answer














      It simply works for me.



      Go in Database ->
      Rules ->



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







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Oct 25 '17 at 8:42

























      answered Oct 25 '17 at 6:44









      Luvnish Monga

      9181119




      9181119












      • Never knew there was something like this.. :) Thanks a lot
        – User-8017771
        Jun 12 at 6:19






      • 4




        note it allows everybody to read,write your database without any authorization.
        – saigopi
        Sep 12 at 11:26










      • This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
        – Duncan Luk
        Oct 30 at 15:21


















      • Never knew there was something like this.. :) Thanks a lot
        – User-8017771
        Jun 12 at 6:19






      • 4




        note it allows everybody to read,write your database without any authorization.
        – saigopi
        Sep 12 at 11:26










      • This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
        – Duncan Luk
        Oct 30 at 15:21
















      Never knew there was something like this.. :) Thanks a lot
      – User-8017771
      Jun 12 at 6:19




      Never knew there was something like this.. :) Thanks a lot
      – User-8017771
      Jun 12 at 6:19




      4




      4




      note it allows everybody to read,write your database without any authorization.
      – saigopi
      Sep 12 at 11:26




      note it allows everybody to read,write your database without any authorization.
      – saigopi
      Sep 12 at 11:26












      This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
      – Duncan Luk
      Oct 30 at 15:21




      This is a horrible solution, this literally just disables security. Go read this instead: firebase.google.com/docs/firestore/security/get-started
      – Duncan Luk
      Oct 30 at 15:21












      up vote
      2
      down vote













      make sure your DB is not empty nor your query is for collection whom not exist






      share|improve this answer

























        up vote
        2
        down vote













        make sure your DB is not empty nor your query is for collection whom not exist






        share|improve this answer























          up vote
          2
          down vote










          up vote
          2
          down vote









          make sure your DB is not empty nor your query is for collection whom not exist






          share|improve this answer












          make sure your DB is not empty nor your query is for collection whom not exist







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '17 at 18:17









          itzhar

          6,96213045




          6,96213045






















              up vote
              2
              down vote













              Go in Database -> Rules ->
              and do this



              service cloud.firestore {
              match /databases/{database}/documents {
              match /{document=**} {
              allow read, write;
              }
              }
              }





              share|improve this answer

















              • 1




                Danger: this gives anyone read and write access to all of your databases
                – Salami
                Oct 9 at 10:09















              up vote
              2
              down vote













              Go in Database -> Rules ->
              and do this



              service cloud.firestore {
              match /databases/{database}/documents {
              match /{document=**} {
              allow read, write;
              }
              }
              }





              share|improve this answer

















              • 1




                Danger: this gives anyone read and write access to all of your databases
                – Salami
                Oct 9 at 10:09













              up vote
              2
              down vote










              up vote
              2
              down vote









              Go in Database -> Rules ->
              and do this



              service cloud.firestore {
              match /databases/{database}/documents {
              match /{document=**} {
              allow read, write;
              }
              }
              }





              share|improve this answer












              Go in Database -> Rules ->
              and do this



              service cloud.firestore {
              match /databases/{database}/documents {
              match /{document=**} {
              allow read, write;
              }
              }
              }






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 21 '17 at 15:52









              Ali hasan

              19015




              19015








              • 1




                Danger: this gives anyone read and write access to all of your databases
                – Salami
                Oct 9 at 10:09














              • 1




                Danger: this gives anyone read and write access to all of your databases
                – Salami
                Oct 9 at 10:09








              1




              1




              Danger: this gives anyone read and write access to all of your databases
              – Salami
              Oct 9 at 10:09




              Danger: this gives anyone read and write access to all of your databases
              – Salami
              Oct 9 at 10:09










              up vote
              -1
              down vote













              Additionally, you may get this error if the collection reference from your code does not match the collection name on firebase.



              For example the collection name on firebase is users, but your referencing it with db.collection("Users") or db.collection("user")



              It is case sensitive as well.



              Hope this helps someone






              share|improve this answer



























                up vote
                -1
                down vote













                Additionally, you may get this error if the collection reference from your code does not match the collection name on firebase.



                For example the collection name on firebase is users, but your referencing it with db.collection("Users") or db.collection("user")



                It is case sensitive as well.



                Hope this helps someone






                share|improve this answer

























                  up vote
                  -1
                  down vote










                  up vote
                  -1
                  down vote









                  Additionally, you may get this error if the collection reference from your code does not match the collection name on firebase.



                  For example the collection name on firebase is users, but your referencing it with db.collection("Users") or db.collection("user")



                  It is case sensitive as well.



                  Hope this helps someone






                  share|improve this answer














                  Additionally, you may get this error if the collection reference from your code does not match the collection name on firebase.



                  For example the collection name on firebase is users, but your referencing it with db.collection("Users") or db.collection("user")



                  It is case sensitive as well.



                  Hope this helps someone







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 28 at 13:11

























                  answered Aug 28 at 8:17









                  Anga Koko

                  4018




                  4018






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46590155%2ffirestore-permission-denied-missing-or-insufficient-permissions%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Costa Masnaga

                      Fotorealismo

                      Sidney Franklin