dimanche 10 mai 2015

Emberfire throwing permission denied error when api does not have authentication

I'm trying to use the hacker news firebase api in an ember app. I've wired up the EmberFire adapter like so

import config from '../config/environment';
import Firebase from 'firebase';
import FirebaseAdapter from 'emberfire/adapters/firebase';

export default FirebaseAdapter.extend({
  firebase: new Firebase(config.firebase)
});

This is the items route

import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    var self = this;
    return new Ember.RSVP.Promise(function(resolve, reject) {
      Ember.$.getJSON('http://ift.tt/1wJYEqh', function(stories) {
        for (var i = 0; i < 30 + 1; i++) {
          self.store.find('item', stories[i]);
        }
        resolve(self.store.all('item'));
      });
    });
  }
});

The way the api works you have to get a list of story ids from .../topstories.json and then you can use firebase to find the stories themselves with the ids.

This is the error I get when I call self.store.find('item', stories[i]);

Error: permission_denied: Client doesn't have permission to access the desired data.

Seems like an error that would get thrown if the client wasn't logged in, but this api is read only and does not have any authentication. I can make a get request to retrieve an item with normal JavaScript or jQuery.




Aucun commentaire:

Enregistrer un commentaire