I made a small test app using FireBase.
Everything works fine when I leave the rules for anyone to have access to the database
".read":"true",
".write":"true"
But when I added permissions in the rules to limit access from where each user can read, I can no longer read anything in apk.
{
"rules":
{
"comandos":
{
"$unit_id":
{
".read":"root.child('unidades').child($unit_id).hasChild(auth.uid)",
".write":"root.child('unidades').child($unit_id).hasChild(auth.uid)"
}
}
}
}
When I simulate reading and writing in the simulator of the firebase itself the rules work perfectly. So I guess I'm doing something wrong with reading.
Login is working perfectly using FirebaseAuth
, I get confirmation by FirebaseAuth.AuthStateListener
, but I do not know how to "connect" this login to my Firebase reference. And when I try to login using
mRef = new Firebase(url);
mRef.authWithPassword(email, pass, new Firebase.AuthResultHandler(){...});
I get the message that I should use FirebaseAuth
,
Projects created at console.firebase.google.com must use the
new Firebase Authentication SDKs available from firebase.google.com/docs/auth/
I should be letting something extremely simple go unnoticed, but I have no idea how to get the data now that I'm requiring a login, since the Firebase reference firebase.getAuth()
is always null, and the data arrives by
firebase.addChildEventListener(new ChildEventListener(){...});
@edit
//build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.firebase:firebase-auth:9.2.0'
}