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

Viewed 676

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.

2 Answers

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

I Resolve the problem by Un-enforced the app check on the firebase console. by doing this

 Project Settings > App-Check > APIs > Cloud Firestore click UnEnforce.

but in my case it still won't work. and i try to disconnect the flutter app with the firebase console and create a new one without connecting the app-check feature, and it work properly now

Related