0

I'm currently trying to integrate a 3rd party API into my website, I am testing the API using Postman (the Chrome Extension) before writing my AngularJS Service (using $http). However I am unsure about one thing. Here is the original curl command provided by the API documentation (I have modified the URL)

curl -i -u "{clientId}:" -H "Content-Type: application/json" -X GET "https://api.thirdparty.com/api/rest/functionality"

Now it's all very simple. I make a get request to the URL and I add the header "Content-Type: application/json". However what do I do for the command -i -u "{clientId}:"? Obviously I have to send this in the header, but I don't know if I am expected to just add another header like "{clientId}:{clientId}" or if I have to pass something different as I am ussure what the -i and -u?

Please note that {clientId} is just a placeholder for a real clientId like '1qw43Q', etc...

Thanks in advance.

Mark Sandman
  • 3,293
  • 12
  • 40
  • 60

1 Answers1

0

If you are asking about jQuery ajax function, which I think you do, you need add this to you ajax call.

beforeSend: function (xhr) {
    xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" +        password));
}

For details see here How to use Basic Auth with jQuery and AJAX?

Community
  • 1
  • 1
speedingdeer
  • 1,236
  • 2
  • 16
  • 26