Here's what I have so far:
var ref = new Firebase('https://url.firebaseio.com/');
ref.authWithPassword({
"email": "email@gmail.com",
"password": "******"
}, function(err, authData) {
if (err) {
console.log(err);
} else {
console.log("Authenticated successfully with payload:", authData);
}
})
I get a message confirming my authentication was successful. However, if I run something like ref.update({}), I get an error saying permission denied. My Firebase security rules look like this:
{
"rules": {
"users": {
"$user_id": {
".read": "auth != null && auth.uid == $user_id",
".write": "auth != null && auth.uid == $user_id"
}
}
}
}
Any advice is appreciated, thanks!
EDIT: Here is the code that I run that giving me the error.
ref.on('value', function(snapshot){
hsObject = snapshot.val(); //hsObject is the entire Firebase document
}, function(err){
hsObject = null;
console.log('error:', err); //prints "error: Error: permission_denied at /: Client doesn't have permission to access the desired data."
});