【问题标题】:Why am I Getting a 403 Error with Blogger API and AngularJS?为什么我在使用 Blogger API 和 AngularJS 时出现 403 错误?
【发布时间】:2017-08-19 17:56:47
【问题描述】:

我刚刚开始着手在 3rd Party API 之上构建,我想添加到我自己的网站(用 AngularJS 编写)的一个功能是构建 Blogger 的 API 以创建博客提要。

我已设置好所有内容,并看到 200 状态作为请求,但网络选项卡中的响应显示:

// API callback
angular.callbacks._0({
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}
);

这是我的控制器:

$http.jsonp('https://www.googleapis.com/blogger/v3/blogs/' + id + '?api_key=' + apiKey).then(function(res) {
    $scope.blogData = res.data;
    console.log($scope.blogData, res);
}, function(error) {
    console.log(error);
});

所以从外观上看请求是成功的,但响应显示身份验证问题。我已经阅读了文档,并且该博客将是公开的,因此机密等方面应该没有任何问题。

有什么想法吗?

【问题讨论】:

  • 你可以尝试去你的谷歌开发控制台看看你是否超出了你的每日配额。

标签: javascript angularjs api google-api blogger


【解决方案1】:

问题在于 url api_key 中的参数。它应该只是 key。 这样就可以了。

$http.jsonp('https://www.googleapis.com/blogger/v3/blogs/' + id + '?key=' + apiKey).then(function(res) {
    ...
}, function(error) {
    console.log(error);
});  

这是来自文档https://developers.google.com/blogger/docs/3.0/using#RetrievingABlog的示例

【讨论】:

  • 是的,解决了这个问题——在我在这里发布消息几分钟后注意到了 url 中的错误。 '?api_key=' 是错误的。不过感谢您的帮助。
猜你喜欢
  • 2021-07-20
  • 2022-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-04
相关资源
最近更新 更多