Firebase "Permission Denied" Error

I am trying to write data from my own account but the Firebase is giving me error “Permission Denied”.

I have set rules so that only the user can read or write only their data and not others. But I logged in with my own account and tried to store data but it is saying “Permission Denied”.

Here are my rules:

I am unable to write or read my own data. Please help me.

{  "rules": 
	{"Admin": 
		{".read": "auth.uid === '<your Admin user uid here>' ",
       	 ".write": "auth.uid === '<your Admin user uid here>' "
     	}
 	}
}
1 Like

Thanks I know this but this is not the problem. I have set it true for testing purposes only. I am having problem with the “Users” bucket. I am unable to read or write data into my own bucket even when I am authenticated.

Read and Write only to a User’s Area
This provides an authenticated user access to just their own content. They can read and write in their own protected area, using the “uid” as the marker for their data

{
  "rules": {
    "<ProjectBucket>": {
       "$uid": {
         ".read": "$uid === auth.uid",
         ".write": "$uid === auth.uid"
       }
     }
   }
}
1 Like

Yes that’s what I have done. Aren’t these rules correct?

Please see the rule for “Users” bucket:

OK, when you login as an authenticated user, you should be able to read and write to your own data area.

You have not shown any blocks, it is possible that you are not providing the uid and idToken correctly when posting/retrieving data from firebase…

I tried but I couldn’t. Please prepare user manual of data writing and reading using firebase permission and code blocks. really much needed.

Can you show the code blocks after completion? (only about reading and writing data)

The rules are now working for me. What problem are you facing?


I can only use it this way. Another user can read someone else’s data.

Try setting your <ProjectBucket> in the rules and use the rules as I indicated above, and/or follow the Firebase Authentication documentation again, which shows the same thing.

These rules will not work if you want user to only read and write his own data. To do that, use a wildcard as user’s UID in your real-time database as a tag and then write these rules:

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

This way it will work if you are following all the steps correctly.

1 Like

ok thank you for your attention

1 Like