扑来:i/flutter(8345):[cloud_firestore/允许被拒绝]呼叫者无权执行指定的操作
我想访问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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道您是否已经解决了问题,但是您遇到的错误是因为您的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.
内部
projectFolder/android/app/src/main/androidmanifest.xml
尝试添加以下内容并重建您的应用程序:Inside
projectFolder/android/app/src/main/AndroidManifest.xml
try add the following and rebuild your app: