本文介绍了Permission_denied访问Firebase数据存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问我的Firebase数据以进行一些测试.我已经在firebase控制台中设置了一个应用,并将访问规则设置为:

I am trying to get access to my firebase data to run a little test. I have setup an app in the firebase console and set the access rules to:

// Allow read/write access to all users under any conditions
// Warning: **NEVER** use this rule set in production; it allows
// anyone to overwrite your entire database.
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

尽管如此,我总是遇到以下错误:

Nevertheless I am always getting the following error:

angular.js:14328 Error: permission_denied at /messages: Client doesn't have permission to access the desired data.

此行代码:

var ref = firebase.database().ref().child('messages');

我想念的是什么?

推荐答案

这些规则适用于Firestore,而不适用于Firebase实时数据库.

Those rules are for firestore and not firebase-realtime database.

在控制台中,转到数据库"部分,然后单击下拉列表,然后选择实时数据库":

In the console go to the database section and click on the dropdown then choose RealTime database:

对于实时数据库,将您的规则更改为此:

For the realtime database change your rules to this:

 {
 "rules": {
   ".read": true,
   ".write": true
  }
}

然后执行测试.

这篇关于Permission_denied访问Firebase数据存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:54