I'm new in Firebase, the problem when i read data after authentication Firebase is PERMISSION DENIED. I research all topic and I found the same problem here: Firebase Permission denied when reading data after authentication . But Frank van Puffelen' answer not work for me. Here is my Firebase rules:
{
"rules": {
"user": {
"$uid": {
"profile": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
},
"account": {
".read": false,
".write": false
},
"shared": {
"$sharedid": {
".read": "auth != null && auth.uid == $uid",
".write": false
}
},
"shared_user": {
".read": false,
".write": false
}
}
},
"node": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
},
"shared": {
"$sharedid": {
".read": "auth != null && root.child('user').child(auth.uid).child('shared').child($sharedid).child('read').val() === true",
".write": "auth != null && root.child('user').child(auth.uid).child('shared').child($sharedid).child('write').val() === true"
}
}
}
}
I found many way but still get PERMISSION DENIED. Please help me!
Edit: Here my authen:
mFirebaseRef= new Firebase("https://my-dashboard.firebaseio.com");
mFirebaseRef.authWithPassword(Constants.EMAIL, Constants.PASSWORD, new AuthResultHandler("password"));
Authen handle:
private class AuthResultHandler implements Firebase.AuthResultHandler{
private final String provider;
public AuthResultHandler(String provider){
this.provider=provider;
}
@Override
public void onAuthenticated(AuthData authData) {
Log.i(TAG, provider + " auth successful");
getData(mFirebaseRef.child("node"));
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
Log.i(TAG, provider+ " auth unsuccessful");
}
}
Finally, get data: ==> Permission denied ?
private void getData(Query ref){
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i(TAG, " onDataChange");
}
@Override
public void onCancelled(FirebaseError firebaseError) {
Log.i(TAG, firebaseError.getMessage());
}
});
}