I'm trying to establish a rule to fetch firestore data, that can be accessed by a google signed in client. So the problem I'm facing is when I'm using this rule
match /helpers/customer/data/{document=**}{
allow read: if request.auth != null;
}
An error pops in logcat
onFailure: Errorcom.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
also it is only working when I'm using
match /helpers/customer/data/{document=**}{
allow read: if true;
}
That means the path is write.
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(this);
if(acct != null){
Log.i(TAG, "onCreate: Database Working");
mFirestoreDB
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
Log.d(TAG, document.getId() + " => " + document.getData());
}
} else {
Log.d(TAG, "Error getting documents: ", task.getException());
}
}
});
}else{
Log.i(TAG, "onCreate: Database not Working");
}
What I need is a rule where I can allow only a google signed in user to access.
mFirestoreDB
? Does it point to a specific collection? – Frank van Puffelen