I have a page that is calling addCheckin()
method which is inside a controller. In the controller, I am trying to create a reference as follows:
var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");
$scope.whichuser
and $scope.whichmeeting
are the $routeParams
that I am passing from another route. Here's my checkin controller-
myApp.controller("CheckinsController", ['$scope','$rootScope','$firebaseArray','$routeParams','$firebaseObject', function($scope,$rootScope,$firebaseArray,$routeParams,$firebaseObject){ $scope.whichuser = $routeParams.uid; $scope.whichmeeting = $routeParams.mid; var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins"); $scope.addCheckin = function(){ var checkinInfo = $firebaseArray(ref); var data={ firstname:$scope.firstname, lastname:$scope.lastname, email:$scope.email, date:firebase.database.ServerValue.TIMESTAMP } checkinInfo.$add(data); } }]);/*controller*/
There are two errors that I am getting here-
Error 1:
Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings: Client doesn't have permission to access the desired data.
Error 2:
Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings/-KT5tqMYKXsFssmcRLm6/checkins: Client doesn't have permission to access the desired data.
And this is what I am tring to achieve-
You can use any Firebase Realtime Database URL as a REST endpoint. All you need to do is append . json to the end of the URL and send a request from your favorite HTTPS client. HTTPS is required.
Firebase Security Rules work by matching a pattern against database paths, and then applying custom conditions to allow access to data at those paths. All Rules across Firebase products have a path-matching component and a conditional statement allowing read or write access.
Go to Firebase console of your app
Select Database From Side Menu --> Select Rule From tabs above --> Update your rule like this
{ "rules": { ".read": true, ".write": true } }
hope it solve your problem . thanks :)
Firebase project by default starts with Firestore as database.
This issue can happen if the application uses "Firebase Realtime Database" and permission for it are not configured. Read and write permission for Firebase Realtime Database should be explicitly granted.
To do so, in Firebase console, Database > Pick "Realtime Database" instead of "Firestore Beta" from the dropdown beside Database > Rules > Set
{ /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ "rules": { ".read": true, ".write": true } }
Hope that help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With