Quite desperate with Firebase rules. Please, help!

Did you add this rule in the existing project?

If so create fresh project in the firebase console and add this app then try

After creating fresh project, try this method.

If you want users to have read access to the whole /users branch but write only to his own user data you might be interested in doing the following:

{
“rules”: {
“users”: {
“.read”: “auth != null”,
“$user_id”: {
“.write”: “auth.uid === $user_id”
}
}
}
}
If you want the user to only see his own user then you should be using $firebaseObject(ref.child(userId)) instead of $firebaseArray. And working with your rules like the following:

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

Then let us know whether it solves or not. If not again we will try for best one.

1 Like

Ok, I’ll make one more fresh Firebase project and see.
For this set of rules

The store value block has to be like this one?blocks
So all the data is under the tag “users” and each users writes and read inside their own UID’s tag. Is that correct?

Thanks again.

Yes, but you forget to add the line / in the join block.

The above structure wont create child in the firebase. It should be users/uid

Screenshot_2

1 Like

Well, fresh Firebase project made and connected to the app. With this set of rules:
imagen
the error message “This client does not have permission to perform this operation” appears if the app is open when the rules are changed. If the app opens after setting the rules the message is “Permission denied” just at the beggining.
With the rules set both to true, no problem, everything works fine.
I left here the aia and the apk.
I’m desperate.
pruebaFirebase.aia (5.0 KB) pruebaFirebase.apk (6.8 MB)

This seems to be the solution!

I worked with the test app, tomorrow I’ll try with the other one.
Thanks.

@Zagal , i used this codes, and finally stored and retrieved the data …

Screenshot_4

Screenshot_3

I made my app work too with the token solution, but in the new Firebase project, in the old one, with the same configuration didn’t work. The old FB project’s servers are in Europe and the new one in USA, maybe the problem is there.
Thanks for all your help!

Does the firebase token id for each user keeps changing?

(If yes then I’ll have to get token id every time the app is opened and if not then I can save it to a tiny db and keep using the same)

Yes, that that token I’d only will become as firebase token then only firebase rule will work/Can be applicable… We have to get it whenevr user sign-up/login

I get this token every time the user open the app. This was the solution to a nightmare with Firebase so I won’t get any risk with this.

1 Like

My app works perfectly for a while after fresh install of apk or after deleting app data and logging in . After stove time it automatically stats giving me permission denied notice.
I have read like 20 or 30 topics and tried everything. I’m sure that the app is logged in when this notice shows. Any help?

This post was flagged by the community and is temporarily hidden.

#off-topic
Dont share the video which are not in english… Already one post was hidden by the mod. Again and again sharing such videos mean there may be the chance for mute/suspending the account…

If the app works fine for what you need, stores and retrieve data without problems but the message keeps appearing, leave this block empty:
imagen
and ignore the error.
If data is not stored or retrieved, even after the id token solution, probably there is a problem with the FB rules.

Sorry to repeat this. We will not repeat this again in the near future. I will do it and publish it translated into English
:kissing_heart:
After completing my studies

1 Like

The firebase rules are simple.

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

The app works perfectly when I freshly install it or when I delete all data and login again. It stops working of I open the app after a while like say overnight.
Its a very wierd problem.

But the problem is related to FB? Which is the error message? Maybe It has to be with the initialize screen block, but we need to know more so we can try to help.

I’ll try this once. If it doesn’t work then shall post my blocks. Thanks for your time