【问题标题】:Firebase Database auth variable does not workFirebase 数据库身份验证变量不起作用
【发布时间】:2016-05-24 14:30:59
【问题描述】:

医生说

Once a user authenticates, the auth variable in your Firebase Database Rules rules will be populated with the user's information. This information includes their unique identifier (uid) as well as linked account data, such as a Facebook id or an email address, and other info.

我用谷歌在我的应用程序中进行了验证,但是当尝试读取数据库时它返回了

Firebase Database error: Permission denied

这是我的规则:

{
  "rules": {
    "msgs":{
    ".read": "auth != null && auth.provider == 'google'",
    ".write":"auth != null && auth.provider == 'google'"
    }
  }
}

【问题讨论】:

    标签: android firebase firebase-realtime-database firebase-authentication


    【解决方案1】:

    尝试 auth !== null 它似乎希望有两个等号。

    【讨论】:

    • 有趣...您确定您正在阅读 msgs 子节点吗?您可以发布您使用 get 到该参考点的代码吗?
    • 是的,因为当我更改 .read 时。写入 true 它工作正常,我在 android 端 DatabaseReference firebaseDatabase = FirebaseDatabase.getInstance().getReference(); DatabaseReference databaseReference = firebaseDatabase.child("msgs");
    • 您是否尝试删除提供程序类型部分以查看您的身份验证是否为空?
    • 你的意思是这样吗? ".read": "auth !== null ", ".write":"auth !== null " ...是同样的问题
    • 好吧,看来验证时出现了问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2021-12-20
    • 2019-04-19
    • 1970-01-01
    • 2017-02-28
    相关资源
    最近更新 更多