无法从Firebase获取数据。授权被拒绝 [英] Can't get data from firebase. Authorization denied
问题描述
我仍然从Firebase开始,并使用angularfire进行连接。
使用google作为提供者,我能够成功地进行身份验证,并且使用我的账户登录并获取了我的用户详细信息,包括uid&图像,但是,当我试图检索任何数据时,我得到: permission_denied在/系列:客户端没有权限访问所需的数据。
我也试过模拟器得到相同的问题。
这是我的数据库:
我的规则:
我在模拟器中输入的数据。我使用谷歌在应用程序中登录后得到了uid:
模拟器:
我应该做什么但不做?
终于找到了答案。由于cartant写道:
没有授予读权限,因为.read默认为false
我需要做的是。read:auth!= null
所以新规则是:
$ p $ {
rules:{
series:{
.read:auth!= null,<<这是缺少
$ uid:{
.read:$ uid === auth.uid,
.write:$ uid === auth。 uid
}
}
}
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?
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"
}
}
}
}
这篇关于无法从Firebase获取数据。授权被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!