I am trying to set rules for the firebase Realtime Database. Rules are set to
"rules": {
".read": true,
".write": true
} This makes it public but I want to set it to private and I want to access it. Not only through the console but the Angular app.
You need to login to get an auth
object and then can use the user-id to restrict access:
{
"rules": {
"users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id === auth.uid"
}
}
}
}
https://firebase.google.com/docs/database/security/rules-conditions#authentication