【问题标题】:custom google search api failed to load resource: net::ERR_EMPTY_RESPONSE status of 401 (Unauthorized)自定义谷歌搜索 api 加载资源失败:net::ERR_EMPTY_RESPONSE 状态为 401(未授权)
【发布时间】:2015-07-10 09:15:26
【问题描述】:

I am following the tutorial at this blog for a simple mean app using a google custom search api,然后我运行搜索并在 grunt 上返回 null 并在控制台上显示“加载资源失败:服务器响应状态为 401(未授权)”,然后“加载资源失败:net::ERR_EMPTY_RESPONSE”。我认为这里需要使用搜索引擎或键之类的东西来完成更多的自定义工作,但我不完全确定从哪里开始,因为我对意思/表达/后端非常陌生。

All of the code can be seen here and I can post specific pieces if needed.

我有一个 google acc、API 项目、API 密钥、google 开发者控制台上的自定义搜索引擎,以及通过 google dev 的 cse id。控制台,我可以轻松地使用他们在 html 页面上发布的脚本进行自定义搜索,所以我认为这方面的一切工作正常。然而,我真的想要一个平均框架来处理使用这个应用程序的调用,这样我就可以在后端学习正确的处理方式。我在谷歌开发者控制台上点击 api,因为它说我每天最多有 100 个请求,我已经使用了其中的 40 个,但是每个请求都有一个客户端错误(4xx)。另一位开发者朋友告诉我,这并不一定意味着它实际上是客户端。所以我有点迷路了。我会继续修补和搜索,但如果您有任何进一步的想法,我很高兴听到。

I remembered something from an internship where some research brought about some info like this。总而言之,jsonp 可能无法与 localhost 的 url 一起使用,因为 1.'Localhost' 是少数 DNS 主机名之一,其含义取决于查询的时间和地点,从而使潜在目标易受攻击。他建议更改主机名。

还有! 我有一个新的和令人兴奋的拼图。 (我不关心这些键,因为这是出于学习目的。我会在需要时生成新的)我已经设法在不使用标题的情况下直接在 Advanced Rest Client 中调用(我应该使用标题吗?) 这个网址: https://www.googleapis.com/customsearch/v1?cx=AIzaSyDYPylFKYXm25ehQNEt8ViC30e74U6kbzE&q=asdf&num=10&key=AIzaSyA5lOVg_veudp8iUMc2GkTMnMXPJrjFNrk

我收到了这个物品!

{
error: {
errors: [1]
0: {
domain: “usageLimits”
reason: “ipRefererBlocked”
message: “There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.”
extendedHelp: “https://console.developers.google.com”
}-
–
code: 403
message: “There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.”
}-
}

是否有特定的方法来包含我将在 Google 开发者控制台上使用的 uri 和 url?

【问题讨论】:

    标签: angularjs node.js express mean-stack google-custom-search


    【解决方案1】:

    我发现很多人通过将 API 设置为允许任何引荐来源网址和任何 IP 来解决此类似问题。这并不理想,但有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 1970-01-01
      • 2021-01-29
      • 1970-01-01
      • 2011-03-18
      • 1970-01-01
      相关资源
      最近更新 更多