简体   繁体   English

Firestore PERMISSION_DENIED

[英]Firestore PERMISSION_DENIED

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.当我编写我的 flutter 应用程序时,我在 macOs 上遇到了这个问题,相同的基本代码在我的 windows pc 上工作,但在 macOs 上它不起作用。 As you can see in my logs, the application is connected but I still cannot make a request on my Firestore database正如您在我的日志中看到的那样,应用程序已连接,但我仍然无法在我的 Firestore 数据库上发出请求

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相同的代码适用于我的 windows PC

Inside projectFolder/android/app/src/main/AndroidManifest.xml add the following:projectFolder/android/app/src/main/AndroidManifest.xml添加以下内容:

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

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).检查您在 androidManifest 文件中是否具有正确的 Internet 权限(由 Abhishek Dutt 建议)。

If you are using an emulator, check if the emulator can access the internet using this post.如果您使用的是模拟器,请检查模拟器是否可以使用此帖子访问互联网

After several I realized that the problem was not only under MacOs but with emulators.几次之后,我意识到问题不仅在 MacOs 下,而且在模拟器上。 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.通过进一步挖掘,我意识到我在项目上激活的 AppCheck 不接受模拟器下调试模式的所有请求。

As mentioned in the docs https://firebase.google.com/docs/app-check/flutter/debug-provider如文档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.当 Firebase 尝试向后端发送请求时,您的应用会将本地调试令牌打印到调试 output。 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.在 Firebase 控制台的 App Check 部分,从应用程序的溢出菜单中选择 Manage debug tokens。 Then, register the debug token you logged in the previous step.然后,注册您在上一步中登录的调试令牌。

Firebase console Firebase 控制台

After you register the token, Firebase backend services will accept it as valid.注册令牌后,Firebase 后端服务会将其视为有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PERMISSION_DENIED Firestore 模拟器 - PERMISSION_DENIED Firestore Emulator firestore:PERMISSION_DENIED:权限缺失或不足 - firestore: PERMISSION_DENIED: Missing or insufficient permissions firestore 备份 function 错误,“PERMISSION_DENIED:调用者没有权限” - firestore backup function errors with "PERMISSION_DENIED: The caller does not have permission" Firebase Cloud Functions Firestore 触发器产生:错误:7 PERMISSION_DENIED:权限缺失或不足 - Firebase Cloud Functions Firestore Trigger produces: Error: 7 PERMISSION_DENIED: Missing or insufficient permissions PERMISSION_DENIED:Cloud IAM 权限“cloudtranslate.generalModels.predict”被拒绝 - PERMISSION_DENIED: Cloud IAM permission 'cloudtranslate.generalModels.predict' denied Firestore 安全规则 - 权限被拒绝 - Firestore security rules - permission denied “gcloud functions logs read ...”给出了PERMISSION_DENIED:权限'logging.views.access' - "gcloud functions logs read..." gives PERMISSION_DENIED: Permission 'logging.views.access' 尝试使用 Ionic4 和 Angular 6 将文档添加到 firebase 时出错 - 错误:PERMISSION_DENIED:权限被拒绝 - Getting error when trying to add document to firebase using Ionic4 and Angular 6 - Error: PERMISSION_DENIED: Permission denied 如何修复错误:(gcloud.functions.deploy)PERMISSION_DENIED:权限'run.services.setIamPolicy'拒绝资源' - How to fix ERROR: (gcloud.functions.deploy) PERMISSION_DENIED: Permission 'run.services.setIamPolicy' denied on resource ' 用于 BigQuery 存储 API 上 Apache Beam 2.39.0 和 DataFlow 运行器的 PERMISSION_DENIED - PERMISSION_DENIED for BigQuery Storage API on Apache Beam 2.39.0 and DataFlow runner
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM