Search code examples
javascriptmeteorapispark

Meteor apispark: unauthorized connection


I am playing with Meteor, and I am trying to make an API call to my apispark account, having a look at the Meteor Documentation: http doc

1 - Meteor.http.get("http://www.google.com")); works fine, returns me the google page.

2 - Meteor.http.get("https://myApi.apispark.net:443/v1/campaigns"));

Exception while invoking method 'getApiCampains' Error: failed [401] {"code":403,"description":"The server understood the request, but is refusing to fulfill it","reasonPhrase":"Forbidden"}

Which seems fine as I didnt provide any auth params.

3 - Meteor.http.get("https://myApi.apispark.net:443/v1/campaigns", {auth : '123:456'});

Exception while invoking method 'getApiCampains' Error: failed [401] {"code":401,"description":"The request requires user authentication", "reasonPhrase":"Unauthorized"}

Where 123 is my username and 456 is my private key. So that is basically what is wrong for me, the two previous examples are here to show that my api calls are working in general, but not this one.

Can anyone see what I am doing wrong here? As I checked one billion time, my credentials are the same one as the one from my account on apispark.

As it is the first time I am playing with Meteor HTTP package and making an API call, I could have easily forgotten something there, maybe some options or something ?

Any help or tips would be really appreciated ! Thanks


Solution

  • Could you make a try with curl to be sure that your credentials are correct? Here is a sample:

    curl -u 123:456 https://myApi.apispark.net:443/v1/campaigns
    

    I just did a try and it works for me. Be sure to use the credentials defined at the level of the Web API within the endpoint section. They are specific for your Web API and different from the ones of your account.

    This link from the documentation could help you: http://restlet.com/technical-resources/apispark/guide/create/test.

    Hope it helps you, Thierry