Firebase DB Rules

I’ve encountered the same problem. I solved it. I don’t know if it’s the right way, but it works for me.

When you first login with google, the user is created in the Authentication section. But it doesn’t let you write data in firebase (with the rules defined for you to write in your own bucket)

I’m not sure, but I think it doesn’t let you write in the firebase database with the same token id you created the user with.
So I solved it by getting another token id and passing it to firebase, and there it lets me write data.

For that I have a screen for google access and another screen to get the token id again…

The structure of my database:


I use these rules:

// Checks auth uid equals database node uid
// In other words, the User can only access their own data

{
“rules”: {
“users”: {
“$uid”: {
“.read”: “$uid === auth.uid”,
“.write”: “$uid === auth.uid”
}
}
}
}

And I use these blocks:

Screen1

Screen2

(The label is just to see if I get the same project bucket)

At the moment it’s working for me

4 Likes