stefano
(stefano)
May 10, 2021, 3:08pm
#1
Hi koders
i try to secure Firebase with this rules
{
“rules”: {
“users”: {
“$uid”: {
“.read”: “$uid === auth.uid”,
“.write”: “$uid === auth.uid”
}
}
Use this block
so that to me it appears random this error comes out
where am i wrong?
stefano
(stefano)
May 10, 2021, 4:23pm
#3
Thank for answer
Can i put rule with users/uid?
No not like that. Refer this post/guide
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…
stefano
(stefano)
May 10, 2021, 5:30pm
#5
I already read the guide and i try to make block same but not function
Show me your rule now
{
“rules”: {
“users":{
“$user ID:
.
.
.
Sorry
After settling rule you can check up there itself
stefano
(stefano)
May 10, 2021, 9:05pm
#8
{
“rules”: {
“users”: {
“$uid”: {
“.read”: “$uid === auth.uid”,
“.write”: “$uid === auth.uid”
}
}
stefano
(stefano)
May 10, 2021, 9:08pm
#9
excuse me
I do not have
I got it
Don’t use uid , if you want then change the global variable name from user ID to uid
Also confirm me, while you creating project in firebase which server you gave? US states or anyother server?
US server only will work without problem for firebase authendication
stefano
(stefano)
May 11, 2021, 4:27am
#12
now i rewrite rule in
{
“rules”: {
“users”: {
“$user_id”: {
“.read”: “$user_id === auth.uid”,
“.write”: “$user_id === auth.uid”
}
},
“Blue”: {
“.read”: true,
“.write”: true
}
}
}
stefano:
also error
Still it is working with no problem in my app
@Zagal , i used this codes, and finally stored and retrieved the data …
[Screenshot_4]
[blocks (1)]
[Screenshot_3]
stefano
(stefano)
May 11, 2021, 5:05am
#15
the problem that works and then without explanation stops working
HeyAveHey
(HeyAveHey)
May 11, 2021, 2:57pm
#16
It’s probably because database component works on a custom token system. Try to set Firebase Token at user succes as in login succes. So everytime user open the app fetch the token and return it to firebase database token.
stefano
(stefano)
May 11, 2021, 3:06pm
#17
I tried the problem I think it is that if the app remains open for more than an hour it expires, can you intercept the error, prevent it from appearing and renew the token?
HeyAveHey
(HeyAveHey)
May 11, 2021, 3:40pm
#18
On firebase database error try to fetch the token ID again an set your firebase database token to it.
stefano
(stefano)
May 11, 2021, 5:26pm
#19
yes I thought of doing so but can I avoid the error appearing by intercepting before it appears?
Enderman
(Shreyansh)
May 11, 2021, 5:58pm
#20
Just Write True in Both Read/Write
stefano
(stefano)
May 11, 2021, 7:54pm
#21