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'
I changed few code lines for setting credential
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
it make works clealy.