I want to restrict access to my Firebase Database, so that only the users I authorize can write to it. But the solution almost everywhere proposed doesn't seem to work for me.
I always get an 401 (unathorized) Error in my Console.
I tried two ways of checking wheter the right user is logged in or not, but none of them worked for me.:
1. uid hard-coded in rules:
{
"rules": {
".read": true,
".write": "auth.uid === 'UID'")",
}
}
2. uid in database
{
"rules": {
".read": true,
".write": "root.child('users').hasChild(auth.uid)",
}
}
In both ways I used the uid provided in the Firebase-Authentication overview. I use Google as Signin provider.