Question

I just created a new application on my Apigee account, settled all roles for Guest on /article but still getting "401 (Unauthorized)" error when trying to fetch the data using the javaScript SDK.

Ps: I can access the data though the usergrid website.

var client = new Apigee.Client({
  orgName: 'MY-ORG-NAME', // Apigee.com username
  appName: 'MyAppName' // Apigee app name
});

var articles = new Apigee.Collection({
  "client": client,
  "type": "articles"
});

...

articles.fetch(
  function() {
    while (articles.hasNextEntity()) {
      var article = articles.getNextEntity();
      $('#lst').append('<li>' + article.get('title') + '</li>');
    }
    $('#lst').listview('refresh');
  }
); //articles.fetch
Was it helpful?

Solution

I still don't know very well the reason but as I was having the problem while testing my app on Chrome, just went to the Resources tab of the Developer Tools, selected Local Storage File:// and deleted the APIGEE_TOKEN. After that I refreshed the app and it worked perfectly.

OTHER TIPS

I am guessing that you are not using the Sandbox application. If that is the case, then you are hitting a security wall because you are not sending a token with your call. For information on security and using tokens, see here:

http://apigee.com/docs/app-services/content/app-security

Delete the local apigee token (or have your app reauthorize) because if you tested prior to setting the GET etc permissions, the token will be for the prior state and apigee will not recognize that you have added the Guest permissions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top