2017-03-09 36 views
0

我仍然开始使用Firebase,并且正在使用angularfire进行连接。 我能够使用谷歌作为提供商成功地进行身份验证,并且使用我的帐户登录并获取了我的用户详细信息,包括图像的uid &,但是,当我试图检索我获得的任何数据时:permission_denied at /series: Client doesn't have permission to access the desired data.我也尝试过模拟器并得到同样的问题。无法从Firebase获取数据。授权被拒绝

这里是我的数据库: enter image description here

我的规则: enter image description here

我在模拟器中输入的数据。我得到了UID在应用程序中使用谷歌签约后: enter image description here

而且使用模拟器后的结果: enter image description here

这里就是我得到了我的UID来自:(验证选项卡) enter image description here

我应该做什么但不做

回答

0

终于找到了答案。作为cartant写道

有理所当然的,因为.read默认为false没有读权限

所有我需要做的是".read": "auth != null"

因此,新的规则是:

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

请注意,有了这些规则,**每个人**都可以读取'/ series'下的所有数据。 '$ uid'下的'.read'规则不会取得任何人的许可。有关详情,请参阅Firebase文档:https://firebase.google.com/docs/database/security/securing-data#read_and_write_rules_cascade –

相关问题