I believe my security rules and code is correct, but I am getting a permission error in Android studio when I try to retrieve from the user document...
This is the Get User Profile method in my Android java code:
public void getUserProfile(){
db.collection("users")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull com.google.android.gms.tasks.Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
String displayName = document.getString("DisplayName");
String userEmail = user.getEmail();
}
} else {
Log.w("DEBUG_FirestoreActivity", "Error getting documents.", task.getException());
}
}
});
}
... and this is how my security rules are set up:
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;}
Here is the output of the error I'm receiving in android studio:
com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
What's strange is that everything should work, and I have tested it with the Rules Playground.