3

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

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mr Magloire
  • 773
  • 8
  • 14
  • There is some useful information written in this article, [How to fix Firestore Error: PERMISSION_DENIED: Missing or insufficient permissions](https://medium.com/firebase-tips-tricks/how-to-fix-firestore-error-permission-denied-missing-or-insufficient-permissions-777d591f404), that might help. – Alex Mamo Jan 13 '22 at 09:00

4 Answers4

6

After several I realized that the problem was not only under MacOs but with emulators. And by digging further I realized that it is AppCheck that I activated on the project which does not accept all the requests of the Debug mode under the emulator.

Mr Magloire
  • 773
  • 8
  • 14
4

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;
          }
       }
    }
  • thank for your response, at the same time, the connection is made via otp verification which opens a web page for the verification by captcha with firebase auth, after i put sms code which verify and I receive the token that you see in the console but get data via firestore is there that there is the problem. – Mr Magloire Jan 12 '22 at 21:46
  • Added some codes to my answer, could you try them – Andres Fiesco Casasola Jan 12 '22 at 23:43
3

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

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Abhishek Dutt
  • 1,308
  • 7
  • 14
  • 24
1

As mentioned in the docs https://firebase.google.com/docs/app-check/flutter/debug-provider

  await FirebaseAppCheck.instance.activate(
    // Set androidProvider to `AndroidProvider.debug`
    androidProvider: AndroidProvider.debug,   );

Your app will print a local debug token to the debug output when Firebase tries to send a request to the backend. For example:

D DebugAppCheckProvider: Enter this debug secret into the allow list in
the Firebase Console for your project: 123a4567-b89c-12d3-e456-789012345678

enter image description here

In the App Check section of the Firebase console, choose Manage debug tokens from your app's overflow menu. Then, register the debug token you logged in the previous step.

Firebase console

After you register the token, Firebase backend services will accept it as valid.