Can't get data from firebase. Authorization denied

牧云@^-^@ 提交于 2019-12-12 05:53:44

问题


I'm still starting out with firebase and i'm using angularfire to connect. I was able to do the authentication successfully using google as a provider and I logged in using my account and got back my user details including uid & image, however, when I attempt to retrieve any data I get: permission_denied at /series: Client doesn't have permission to access the desired data. I also tried the simulator and got the same issue.

Here's my database:

My rules:

The data I entered in the simulator. I got the uid after signing in using google in the app:

And the result after using the simulator:

Here's where I got my UID from: (The authentication tab)

What am I supposed to be doing but not doing?


回答1:


Finally found the answer. As cartant wrote

there are no read permissions granted, as .read defaults to false

all I needed to do was to ".read": "auth != null"

So the new rules are:

{
  "rules": {
    "series": {
      ".read": "auth != null", << THAT WAS MISSING
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}


来源:https://stackoverflow.com/questions/42690615/cant-get-data-from-firebase-authorization-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!