0

My users are sometimes affected by FirebaseFirestoreException: PERMISSION_DENIED

FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
    at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:117)
    at com.google.firebase.firestore.core.EventManager.onError
    at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:588)
    at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:424)
    at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99

My app is live for around a month and it has around 10000 users. I've received around ~25 reports so far. I have no idea what the issue can be. This is my Firestore setup:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /coupons/{coupon} {
      allow read: if isAuthenticated();
    }
    
    match /users/{userId} {
      allow read, update, delete: if isAuthenticated() && isOwner(userId);
      allow create: if isAuthenticated();
    }
    
    function isAuthenticated() {
        return request.auth != null
    }
    
    function isOwner(userId) {
        return request.auth.uid == userId
    }
  }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mariusz
  • 1,825
  • 5
  • 22
  • 36
  • The Firebase Realtime Database and Cloud Firestore are two separate databases. Please only mark your question with the relevant tag, not with both. --- Aside from that, without seeing the [code that causes the error](http://stackoverflow.com/help/mcve), it'll be hard to say more than the obvious: somehow your app is trying to access data that the user doesn't have access to. – Frank van Puffelen Dec 09 '21 at 15:27
  • May be you have your app check enabled as mentioned in this [stackoverflow thread](https://stackoverflow.com/a/70347185/15774177) – Zeenath S N Dec 14 '21 at 12:52

0 Answers0