'flutter app suddenly can't fetch data from firestore, Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

i've been searching for a lot of problem that relate with this but i still didn't find the solution the error say

Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, linking, allowed)

[WriteStream]: (26986c6) Stream closed with status: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}.

[Firestore]: Write failed at users/rX5LRztKddW1c8RIBqyNShligJV2: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

and i've tried to change the firebase firestore rules in my console to be like this

service cloud.firestore {
match /databases/{database}/documents {
 match /{document=**} {
  allow read, write: if request.auth != null;
  }
 }
}

and after that still didnt affect anything. ussualy i still can fetch data into a list and show in a gridview without having a user to login. but now even when i log the user in it still didnt give me any of data. been check my dart code too and didnt find anything suspicious. tried to unintall and install it back. nope didnt works too.



Solution 1:[1]

Did you try like this

allow read, write: if request.auth.uid != null;

or

 service cloud.firestore {   match /databases/{database}/documents {
 match /{document=**} {
   allow read: if auth != null;
   allow write: if auth != null;
 }   } }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gejaa