Reputation: 7732
How the heck do you use the Bing API (now Azure Marketplace API)? Does it only support oAuth? Can anyone show me an example of how to authenticate to it? The documentation is silent and after an hour of frustration I'm posting the question here.
Here is the end point I am trying to hit:
https://api.datamarket.azure.com/Bing/Search/v1/Composite?query=sushi&sources=web
This throws up Basic Auth; if I cancel I get an error message saying that only Basic and oAuth are supported.
However, no combination of username and password known to my account works for Basic, and I can't find an example of how to use oAuth with it. I have an account set up, I have subscribed to the free tier.
Upvotes: 3
Views: 799
Reputation: 7732
After doing more research and experiment I was able to figure it out. The examples confused me (I think theyassume a lot of context about Azure's SOAPy conventions over REST, such as case sensitivity and quoted strings). Perhaps they will confuse others so I'm posting my answer here:
function searchBing() {
var request=require('request');
var url="https://api.datamarket.azure.com/Bing/Search/v1/Web?Query='sushi'&$format=JSON";
var key="[your account key]";
request.get(url, {auth: { user: key, password: key} }, function (error, result) {
console.log(error, result.body);
})
}
Upvotes: 2