编程语言
首页 > 编程语言> > javascript-Google通过Places Web Service取消了引荐来源网址限制的API密钥

javascript-Google通过Places Web Service取消了引荐来源网址限制的API密钥

作者:互联网

我最近收到了Google的一封电子邮件,通知我:

You are receiving this email because your project is using Places Web
Service API with an API Key with HTTP referer restrictions. (…)
starting January 31 2018 the Places Web Service API will no longer
accept API Keys with HTTP Referer usage restrictions.

我的代码仅使用Javascript Maps和Places API,其代码例如

new google.maps.places.AutocompleteService();
new google.maps.places.PlacesService(document.createElement("div"));

深入了解Google Places for Javascript文档的API,i found out that

Before using the Places library in the Google Maps JavaScript API,
first ensure that the Google Places API Web Service is enabled in the
Google API Console, in the same project you set up for the Google Maps
JavaScript API.

所以我不确定该怎么做.
我使用http Referer受限键来使用Google Maps JS API,这是正确的,并且不建议使用.但是,Google Maps JS API本身使用Places API Web服务,因此我无法使用http Referer受限键.

我应该如何处理这种情况?

解决方法:

对困惑感到抱歉.

我查看了您的当前情况,发现您不需要更新API密钥.

HTTP参照网址受限制的API密钥将继续用于Places Library,这是Maps JavaScript API的一部分:
https://developers.google.com/maps/documentation/javascript/places

如果您直接将Places API与密钥结合使用,则HTTP Referer受限API密钥将停止工作.它将继续适用于Maps JavaScript API,包括Places Library和Services:
https://developers.google.com/maps/documentation/javascript/directions

>指示服务
>距离矩阵服务
>高程服务
>地理编码服务

标签:google-places-api,google-maps-api-3,javascript
来源: https://codeday.me/bug/20191110/2015186.html