All the docs I've found describe how to read and write data to Firebase Realtime Database when setting the privacy of the database to public, like here:
https://firebase.google.com/docs/database/android/read-and-write
Firebase Permission denied Error
How do I pass the Firebase user when I already have the authentication up and running to be validated when I need to read the data when my rules are like this:
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
When I try like this:
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = dataSnapshot.getValue(String.class);
Log.d("VERBOSE: ", "Value is: " + value);
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("ERROR: ", "Failed to read database.", databaseError.toException());
}
});
I always get the exception
com.google.firebase.database.DatabaseException: Firebase Database error: Permission denied
Best regards