Home > Blockchain >  Firestore PERMISSION_DENIED
Firestore PERMISSION_DENIED

Time:01-13

i have this problem on macOs when i code my flutter App, The same base code work in my windows pc but in macOs it don't work. As you can see in my logs, the application is connected but I still cannot make a request on my Firestore database

I changed the rule which was

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

to

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

but i have the same error.

D/FirebaseAuth(11790): Notifying id token listeners about user ( tNGS8j375AYehEPDhZADPP80zLY2 ).
W/DynamiteModule(11790): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(11790): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(11790): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/Firestore(11790): (24.0.0) [Firestore]: Listen for Query(target=Query(usersProDEV where uuid == tNGS8j375AYehEPDhZADPP80zLY2 order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
E/flutter (11790): [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.

The same code work in my windows PC

CodePudding user response:

Inside projectFolder/android/app/src/main/AndroidManifest.xml add the following:

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

CodePudding user response:

According to this post, there is an error with your app accessing the internet. Please check your network connection:

Check that you have the proper internet permissions in the androidManifest file (suggested by Abhishek Dutt).

If you are using an emulator, check if the emulator can access the internet using this post.

1st edition:

Can you please try this example code from this documentation for authentication:

  service cloud.firestore {
      match /databases/{database}/documents {
        match /messages/{document=**} {
          allow read, update, delete: if request.auth.uid == resource.data.uid;
          allow create: if request.auth.uid != null;
        }
      }
    }

This code must work only for reading and not writing:

   service cloud.firestore {
        match /databases/{database}/documents {
         match /{document=**} {
           allow read: if true;
           allow write: if false;
          }
       }
    }
  •  Tags:  
  • Related