Firebase权限被拒绝 [英] Firebase permission-denied
本文介绍了Firebase权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Firebase的新手.
I'm a newbie in firebase.
如何通过以下规则?
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
我尝试将规则更改为以下
I've tried to change the rule to below,
{
"rules":
{
".read": true,
".write": true,
}
}
但是有一个错误
mismatched input '{' expecting {'function', 'service', 'syntax'}
下面是数据库结构.
当前,这是我的代码(一直返回被拒绝的权限):
Currently, this is my code (which keeps returning Permission-denied):
// [START initialize_database_ref]
mDatabase = FirebaseDatabase.getInstance().reference
// [END initialize_database_ref]
val result = HashMap<String, Any> ()
result.put("timestamp", getCurrentTime())
result.put("user_id", USER_ID)
result.put("x_position", -1)
result.put("y_position", -1)
mDatabase!!.ref.child("raw data").child("Z9QD79lDzP7MpD6feWeJ").setValue(result).addOnFailureListener(object : OnFailureListener {
override fun onFailure(@NonNull e: Exception) {
Log.d("firebase", e.localizedMessage)
}
})
任何帮助将不胜感激!谢谢:)
Any help would be appreciated! Thanks :)
推荐答案
我能够通过从Cloud Firestore切换到实时数据库,然后更改规则来解决该问题. (更改此设置后,不再显示任何错误!)
I was able to solve the problem by switching from Cloud Firestore to Realtime Database, and then changing the rule. (After I've changed this, there was no more error showing!)
这篇关于Firebase权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文