oauth - 如何使用 Bing 的搜索 API?

标签 oauth get bing

我很难理解 Oauth 验证。我正在尝试使用 bing 的搜索 api。他们要求oauth验证。我有他们给我的主键。我遇到的问题是如何发出请求,提供 oauth 验证 key 。

例如,如果我尝试通过以下方式发出获取请求:

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

我收到一个错误

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

所以问题是,我是否将我的 key 嵌入到 URL 中,比如

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

如何提供我的凭据以访问他们的 API?

最佳答案

这不是一个完整的答案,因为我仍然收到“401 Unauthorized”错误,但这是我为 AngularJS 配置 OAuth 的方式。这是用于 Bing 图像搜索。

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); 
    });

这至少消除了授权类型 错误,但我提供帐户 key 的方式似乎仍然存在错误。希望它能帮助您指明正确的方向!

关于oauth - 如何使用 Bing 的搜索 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30270935/

相关文章:

algorithm - Restful : Using POST to execute algorithms

css - 谷歌和/或必应爬虫是否惩罚隐藏的推特 Bootstrap 标签内的内容

google-chrome - Bing Maps v8.0 Microsoft.Maps.Location 不是 chrome 中的构造函数

android - Google OAuth 登录页面 'cancel' 和 'accept' 按钮从 8 月 22 日起不再启用

python - 带有 OAuth 和 Python 的 Gmail API - AccessTokenRefreshError : invalid_grant

http - Spring RestTemplate - 带有请求正文的 http GET

bing - 有没有办法获取 Bing 当天的照片?

python - 在 Django 中创建自定义用户模型的指南

php - oAuth 中的 access token 是否应该在用户每次登录时生成?

如果执行者在 Web 服务上获取 Android Activity 就会死掉