gpt4 book ai didi

flutter - Firestore PERMISSION_DENIED

转载 作者:行者123 更新时间:2023-12-05 00:43:13 36 4
gpt4 key购买 nike

当我编写我的 flutter 应用程序时,我在 macOS 上遇到了这个问题,相同的基本代码在我的 windows pc 中工作,但在 macOS 中它不起作用。正如您在我的日志中看到的,应用程序已连接,但我仍然无法在我的 Firestore 数据库上发出请求

我改变了规则

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

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

但我有同样的错误。

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.

相同的代码在我的 Windows PC 中工作

最佳答案

据此post ,您的应用程序访问互联网时出现错误。请检查您的网络连接:

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.

第一版:

你能试试这个 documentation 中的示例代码吗?用于身份验证:

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

此代码必须仅适用于读取而不是写入:

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

关于flutter - Firestore PERMISSION_DENIED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70685823/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com