扑来:i/flutter(8345):[cloud_firestore/允许被拒绝]呼叫者无权执行指定的操作

发布于 2025-02-08 04:10:44 字数 2446 浏览 2 评论 0原文

我想访问Firebase的数据以显示在我的应用程序中。我已经使用Firebase在此应用程序上工作了几天,但是今天我有一个错误说 我的代码:

StreamBuilder<QuerySnapshot>(
                    stream:
                        FirebaseFirestore.instance.collection('videos').snapshots(),
                    builder: (BuildContext context,
                        AsyncSnapshot<QuerySnapshot> snapshot) {
                      if (snapshot.hasError) {
                        return Text('Something went wrong!');
                      }
                      if (snapshot.connectionState == ConnectionState.waiting) {
                        return Center(child: CircularProgressIndicator());
                      }
                      return ListView(
                        shrinkWrap: true,
                        physics: ClampingScrollPhysics(),
                        children:
                            snapshot.data!.docs.map((DocumentSnapshot document) {
                          Map<String, dynamic> data =
                              document.data()! as Map<String, dynamic>;
                          return GestureDetector(
                            onTap: () {},
                            child: HomeDisplayScreen(
                              videoLink: data['videoLink'],
                              imageUrl: data['imageUrl'],
                              title: data['title'],
                              likes: data['likes'],
                            ),
                          );
                        }).toList(),
                      );
                    })

错误:

W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(videos order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(users/*****@gmail.com order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
I/flutter ( 8345): [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

我还将安全规则更改为此

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

,我遇到了相同的错误

I want to access data from my firebase to display in my app. And I have been working on this app with Firebase for a few days, but today I got an error saying
my code :

StreamBuilder<QuerySnapshot>(
                    stream:
                        FirebaseFirestore.instance.collection('videos').snapshots(),
                    builder: (BuildContext context,
                        AsyncSnapshot<QuerySnapshot> snapshot) {
                      if (snapshot.hasError) {
                        return Text('Something went wrong!');
                      }
                      if (snapshot.connectionState == ConnectionState.waiting) {
                        return Center(child: CircularProgressIndicator());
                      }
                      return ListView(
                        shrinkWrap: true,
                        physics: ClampingScrollPhysics(),
                        children:
                            snapshot.data!.docs.map((DocumentSnapshot document) {
                          Map<String, dynamic> data =
                              document.data()! as Map<String, dynamic>;
                          return GestureDetector(
                            onTap: () {},
                            child: HomeDisplayScreen(
                              videoLink: data['videoLink'],
                              imageUrl: data['imageUrl'],
                              title: data['title'],
                              likes: data['likes'],
                            ),
                          );
                        }).toList(),
                      );
                    })

the error:

W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(videos order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(users/*****@gmail.com order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
I/flutter ( 8345): [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

I also changed my security rules to this

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

Still, I am getting the same error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2025-02-15 04:10:45

我不知道您是否已经解决了问题,但是您遇到的错误是因为您的Firestore规则,因此要将其修复到Firestore规则中并更改它们。

I don't know if you already fix your problem but the error you got, was because of your Firestore rules so to fix it go into firestore rules and change them.

一抹微笑 2025-02-15 04:10:45

内部projectFolder/android/app/src/main/androidmanifest.xml尝试添加以下内容并重建您的应用程序:

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

Inside projectFolder/android/app/src/main/AndroidManifest.xml try add the following and rebuild your app:

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文