Firestore未能获得子收集,而权限拒绝了错误

发布于 2025-02-01 20:40:44 字数 1315 浏览 5 评论 0原文

我想使用Java库获取所有子收集的文档。

我的firestore的数据高于

/groups/group1/posts/post1
/groups/group1/users/user1

我的规则,我设定允许所有测试请求。

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

这是我的Java代码

Iterable<CollectionReference> collections =
  db.collection("groups").document("group1").listCollections();

for (CollectionReference collRef : collections) {
  System.out.println("Found subcollection with id: " + collRef.getId());
}

,但我遇到此错误

Caused by: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Missing or insufficient permissions.
    at io.grpc.Status.asRuntimeException(Status.java:535)

已更新

,这不是Android SDK,官方文档是在这里

,这是我的build.gradel的一部分

implementation 'com.google.cloud:google-cloud-firestore:3.2.0'
implementation group: 'com.google.cloud', name: 'google-cloud-storage', version: '2.7.1'

I want to get documents with all subcollections using java library.

My firestore has data above

/groups/group1/posts/post1
/groups/group1/users/user1

this is my rule, I set to permit all request for test.

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

this is my java code

Iterable<CollectionReference> collections =
  db.collection("groups").document("group1").listCollections();

for (CollectionReference collRef : collections) {
  System.out.println("Found subcollection with id: " + collRef.getId());
}

but I met this error

Caused by: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Missing or insufficient permissions.
    at io.grpc.Status.asRuntimeException(Status.java:535)

updated

this is not android sdk, official document is here

and this is my part of build.gradel

implementation 'com.google.cloud:google-cloud-firestore:3.2.0'
implementation group: 'com.google.cloud', name: 'google-cloud-storage', version: '2.7.1'

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

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

发布评论

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

评论(1

旧时浪漫 2025-02-08 20:40:44

我更改了几行以设置凭据,

  .setCredentialsProvider(FixedCredentialsProvider.create(credentials))

它使其使工作变得clelaly。

I changed few code lines for setting credential

  .setCredentialsProvider(FixedCredentialsProvider.create(credentials))

it make works clealy.

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