此 IP、站点或移动应用程序未被授权使用此 API 密钥

我正在使用 https://maps.googleapis.com/maps/api/geocode/json?链接到服务器密钥和用户 IP 找到任何地址的经纬度,当我尝试我发现错误为

I have a server access key from google and I have put my server's IP address in the their white list.

我试图通过 PHP CURL 访问的 URL 是:

Https://maps.googleapis.com/maps/api/geocode/json?address=1600+amphitheatre+parkway,+mountain+view,+ca&sensor=true&key=xxxxxxxxxxxx

我得到的结果是:

Array ([error_message] => This IP, site or mobile application is not authorized to use this API key. [results] => Array ( ) [status] => REQUEST_DENIED)

Is there anything that I need to configure.The geocoding API is also switched on.

161034 次浏览

除了分配给您的 API 密钥之外,Google 还通过查看 REFERRER或 IP 地址来验证传入请求的来源。若要在 curl 中运行示例,请在 Google API 控制台中创建一个新的 Server Key。在创建它时,必须提供服务器的 IP 地址。在这种情况下,它将是你的 本地 IP 地址本地 IP 地址。一旦您创建了一个 Server Key并将您的 IP 地址列入白名单,您应该能够在 curl 中使用新的 API 键。

我的猜测是,您可能创建了您的 API 密钥作为一个 Browser Key,它不需要您将您的 IP 地址列入白名单,而是使用 REFERRER HTTP 头标记进行验证。Curl 默认情况下不会发送这个标签,所以 Google 无法验证您的请求。

创建一个没有引用程序的密钥 dont enter the referer address

我也有同样的问题,我发现了这个。

在 url 上,它最终需要服务器密钥,而不是应用程序的 api 密钥。

所以基本上,你只需要在 URL 的末尾添加服务器密钥,就像这样:

Https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&sensor=true&key=serverkey

现在,要获得服务器密钥,只需要 遵循以下步骤:

转到开发者控制台(Developer Console) https://code.google.com/apis/Console/

2) 在凭据中,在 Public API Access 下,创建新密钥

3) 从选项中选择服务器密钥。

4) 在字段中输入你的 IP 地址,如果你有更多的 IP 地址,你可以直接在每一行上添加。 注意:只有当你想用 IP 地址进行测试时才输入 IP 地址。否则将 IP 地址部分保留为空白。

5) 完成后,单击 create,将生成新的 Server Key,然后可以将该服务器密钥添加到 URL 中。

最后一件事是,不要在 URL 的中间放入 Sensor = true,你可以像这样在最后添加它:

Https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&key=serverkey&sensor=true

这肯定会解决这个问题,只要记住使用 Places API的服务器密钥即可。

剪辑

I believe the web URL has changed in the past years. You can access developers console from here now - https://console.developers.google.com/apis/dashboard

  • 导航到开发人员控制台 -https://console.developers.google.com/或使用来自详细信息的链接直接导航到 API 仪表板。
  • 在开发人员控制台下,从左侧导航面板中找到 标签
  • 选择项目
  • 从左侧导航面板中选择 证件
  • 您可以根据需要从 顶级导航酒吧创建凭据类型。

希望这个答案能对你和其他观众有所帮助。祝你好运... ... :)

GooglePlaceAPI 要求在进行 API 调用时包含引用 HTTP 头。

包含 HTTP 头“ Referer: yourdomain.com”,这应该可以修复响应问题。

对于给定的项目,还应该启用相应的 API

Https://console.developers.google.com/apis/library?project=projectnamehere

GooglePlaces API 目前不支持从 GoogleAPI 控制台生成的 Android 或 iOS 密钥。目前只支持服务器和浏览器密钥。

  url = https://maps.googleapis.com/maps/api/directions/json?origin=19.0176147,72.8561644&destination=28.65381,77.22897&mode=driving&key=AIzaSyATaUNPUjc5rs0lVp2Z_spnJle-AvhKLHY

仅在“应用委托”中添加,如

            GMSServices.provideAPIKey("AIzaSyATaUNPUjc5rs0lVp2Z_spnJle-AvhKLHY")

并删除此 URL 中的键。

现在轮到网址了

https://maps.googleapis.com/maps/api/directions/json?origin=19.0176147,72.8561644&destination=28.65381,77.22897&mode=driving
  1. 选钥匙
  2. API Restriction tab
  3. 选择 API 键
  4. 保存
  5. 选择应用程序限制-> 无
  6. 保存

enter image description here

enter image description here

enter image description here

enter image description here

对于 API 的最新版本来说,情况似乎恰恰相反。

当调用 url https://maps.googleapis.com/maps/api/geocode/json?address=<address>&key=<key>时,我得到了以下错误

您必须使用一个 API 密钥来验证对 GoogleMaps 平台 API 的每个请求。有关详细信息,请参阅 http://g.co/dev/maps-no-account

Once I switched the order to https://maps.googleapis.com/maps/api/geocode/json?key=<key>&address=<address> it worked fine.

Note that the error message received above was the message I got when going directly to the URL in the browser. When I called the API from a software program I received an HTML response with basically the following message:

我们很抱歉... 但您的计算机或网络可能会发送自动查询。为了保护我们的用户,我们现在不能处理你的请求。

对于 iOS 或 Android 应用程序,密钥需要额外的特权。

进入谷歌控制台-> API 和服务-> 库。点击平台的 Places 库,然后点击 Enable。

参见 https://developers.google.com/maps/gmp-get-started#enable-api-sdk

您正在尝试使用一个 API KEY,但您以不允许此操作的方式限制了它。

According to Google:

Note: If you need to call web, web service, and/or mobile APIs from the same (client-side) app, create and restrict multiple keys.

因此,正确的做法是创建另一个 API KEY,并为此选择正确的限制。在您的情况下,选择“ IP 地址”(在“应用程序限制”下) ,并使用“ ADDANITEM”添加您的服务器 IP。 请注意,留下一个空白列表不会工作,并将导致谷歌改变您的限制为“无”。

另外,不要忘记在“ API 限制”下添加相关的 API (在您的例子中是“ Geocoding API”)。

最后一件事-谷歌正在阻止这个 API 的使用,直到你把你的应用程序链接到谷歌云计费帐户。因此,如果你还没有做,一旦你成功地得到响应,它会说你必须先做(它有一个免费的启动软件包)。

禁用方向 API 和地理编码 API 并重新启用。

它的工作只有5-10秒,然后自动禁用自己。

这意味着你只有5-10秒来测试你的作业。

认证、配额、定价和策略 认证 要使用 Directions API,必须首先启用 API 并获得适当的身份验证凭据。有关更多信息,请参见入门谷歌地图平台。

Quotas and pricing Review the usage and billing page for details on the quotas and pricing set for the Directions API.

政策 使用方向 API 必须符合 API 策略。

more know : visit:--- https://developers.google.com/maps/documentation/directions/start?hl=en_US