Basically, i am trying to read data from a firebase real time database. I receive permissions denied.
Firebase Console -> database -> Rules :
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
My application code:
const db = firebase.database(firebase.initializeApp(
{databaseURL: “myApp.firebaseio.com"}
))
db.ref("/budgets/currentBudget")
.once("value")
.then((snapshot)=>console.log(snapshot))
I would expect to connect to the database and be able to read the data because of the rules i have set. I receive this error:
Error:
index.cjs.js:738 Uncaught (in promise) Error: permission_denied at /budgets/currentBudget: Client doesn't have permission to access the desired data.
at errorForServerCode (index.cjs.js:738)
at onComplete (index.cjs.js:10124)
at Object.onComplete (index.cjs.js:14314)
at index.cjs.js:13289
at PersistentConnection.onDataMessage_ (index.cjs.js:13594)
at Connection.onDataMessage_ (index.cjs.js:12735)
at Connection.onPrimaryMessageReceived_ (index.cjs.js:12728)
at WebSocketConnection.onMessage (index.cjs.js:12607)
at WebSocketConnection.appendFrame_ (index.cjs.js:12144)
at WebSocketConnection.handleIncomingFrame (index.cjs.js:12203)
at WebSocket.mySock.onmessage (index.cjs.js:12078)
There are a few questions asking about this but most of them are solved when the rules are simply changed to true on both read and write. Any ideas how to get this working?