How do I use the Bing Search API?

I am having a hard time understanding Oauth validation. I am trying to use bing search api. They ask for verification. I have a primary key that they gave me. The problem I am having is how to make a request by providing an oauth verification key.

For example, if I try to make a get request like this:

http//api.datamarket.azure.com/Bing/Search?Query=%27xbox%27

      

I am getting the error

The authorization type you provided is not supported.  Only Basic and OAuth are supported

      

So the question is, should I embed my key in the url, something like

http//api.datamarket.azure.com/Bing/Search?Query=%27xbox%27&authetication="myautherizationkey"

      

How do I provide my credentials to access their api?

+3


source to share


1 answer


This is not a complete answer because I am still getting a 401 Unauthorized error, but this is how I set up my OAuth for AngularJS. This is for Bing Image Search.

var accountKey = '/*Your Account Key*/';
    var base64EncodedKey = btoa(accountKey);
    $http({
      method: 'GET',  
      url: 'https://api.datamarket.azure.com/Bing/Search/v1/Image?Query=%27Pizza%27&$format=JSON',
      headers: {'Authorization': 'Bearer ' + base64EncodedKey}
    }).success(function(json) {
      console.log('Returned: ' + JSON.stringify(json)); 
    }).error(function(err) {
      console.log('There was an error retrieving the image JSON: ' + err); 
    });

      



This at least gets rid of the authorization type error, but I still have an error with the way I provide the account key. Hope this helps you in the right direction!

0


source







All Articles