Firebase DB Rules

so… what should i do?

https://docs.kodular.io/guides/component-examples/securing-app/#writing-the-rules

This may help you.

4 Likes

It’s weird because this only works if the user had already logged in, if it is the first time of someone in app, the error “FirebaseError: Permission denied” appears. I’ve made an app from zero, i simply copied and pasted the tutorial, but the result were the same.

Hi, the @kodular team said they are working to fix the problem with the firebase rules, right now they only work on read, write true or false. I hope they solve it soon as I cannot move forward without proper rules being set up.

2 Likes

so the only option is to wait?

I hope they solve it soon as I cannot move forward without proper rules being set up.

i’m in the same situation…

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

Thank you for posting the solution. In the first image, these large numbers and letters “names” are the userId?

Yes, these are the userIds

I am getting this error:

The error says it all, replace all “ ”:with " "

1 Like

This again

Again try using " ". You are using " instead of ". Read the error carefully please

As Dora says, it’s the quotes.

Change all the quotes (usually Shift + 2)

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

Please note that firebase authentication does not work in companion

1 Like