Permission_denied to access firebase datastore

2019-03-06 15:28发布

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.

at this line of code:

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

What I am I missing?

1条回答
仙女界的扛把子
2楼-- · 2019-03-06 16:00

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:

enter image description here

For the realtime database change your rules to this:

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

and then perform the tests.

查看更多
登录 后发表回答