Google Places API始终返回错误

时间:2022-10-10 09:42:28

I have integrated Google Places API in my android application. I have read the api documentation See Here.

我在我的Android应用程序中集成了Google Places API。我已经阅读了api文档。

I have activated Google Places Api for android and generated browser key and when i call api get error in response -

我已激活Google Places Api for android并生成浏览器密钥,当我调用api时收到错误响应 -

{"error_message" : "This API project is not authorized to use this API.Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
  "html_attributions" : [],
  "results" : [],
  "status" : "REQUEST_DENIED"
}

I also try creating android key and it return -

我也尝试创建android键,它返回 -

{
 "error_message" : "This IP, site or mobile application is not authorized to use this API key.",
 "html_attributions" : [],
 "results" : [],
 "status" : "REQUEST_DENIED"
}

I am not getting what the problem in my code.

我没有得到我的代码中的问题。

Any help is appreciated. Thanks in advance.

任何帮助表示赞赏。提前致谢。

Check API Console - Google Places API始终返回错误

检查API控制台 -

11 个解决方案

#1


I had the same problem. In my case the problem was that I tried to send request using simple HttpUrlconnection by this url:

我有同样的问题。在我的情况下,问题是我试图通过这个url使用简单的HttpUrlconnection发送请求:

 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=62.25227243964484%2C59.12338379770518&radius=500&key=my_key

Where my_key was a key for Google Places API for Android, but when I switched to Google Places API Web Service, this works fine. It seems that for using key for Google Places API for Android you should follow this guide https://developers.google.com/places/android/

my_key是Google Places API for Android的关键,但是当我切换到Google Places API Web服务时,这很好用。对于使用适用于Android的Google Places API的密钥,您应该遵循以下指南https://developers.google.com/places/android/

#2


It looks like you're using the Places API Web Service, which requires enabling "Google Places API Web Service" and providing a server key: https://developers.google.com/places/webservice/intro#Authentication

您似乎正在使用Places API网络服务,该服务需要启用“Google Places API网络服务”并提供服务器密钥:https://developers.google.com/places/webservice/intro#Authentication

Since you're building an Android application, you may want to try the Places API for Android, which we just released in March :) The documentation is available at https://developers.google.com/places/android/

由于您正在构建Android应用程序,因此您可能需要尝试我们刚刚在3月发布的Android版Places API :)该文档位于https://developers.google.com/places/android/

I hope this helps!

我希望这有帮助!

#3


I solved this problem by following below prerequisites:

我通过以下先决条件解决了这个问题:

1) Make sure you are using below URL

1)确保使用以下URL

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=YOURSEARCHTEXT&key=YOUR_SERVER_API_KEY. Don't use your android/IOS API key.

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=YOURSEARCHTEXT&key=YOUR_SERVER_API_KEY。不要使用您的android / IOS API密钥。

2) Make sure you have enabled following API in the console.

2)确保在控制台中启用了以下API。

Google Places API Web Service (Paid Service)

Google Places API网络服务(付费服务)

#4


Actually I was also suffered from this problem but enabling "Google Places API Web Service" worked for me.

实际上我也遇到了这个问题,但启用“Google Places API Web Service”对我有用。

The problem is that we are using Google Places's Web Service for getting Places and we are forget to enable Google Places API Web Service in Google developer console.

问题是我们使用Google商家信息网站服务获取商家信息,但我们忘记在Google开发者控制台中启用Google商家信息API网络服务。

So please make sure that whenever you are using Google Place API and don't forget to enable Google Maps Android API and Google Places API Web Service .

因此,请确保您在使用Google Place API时不要忘记启用Google Maps Android API和Google Places API Web服务。

#5


Make sure Have you enabled Google Places API Web Service. Because Google Places API for Android not for it.
hope it will work.
if not then use a simply url "https://maps.googleapis.com/maps/api/place/autocomplete/json?key=YOUR_API_KEY&components=country:gr&input=YOUR_INPUT_VALUE" like POSTJSON Thank you.

确保您是否启用了Google Places API Web服务。因为适用于Android的Google Places API不适合它。希望它会奏效。如果没有,那么请使用简单的网址“https://maps.googleapis.com/maps/api/place/autocomplete/json?key = YOUR_API_KEY&component / country = gr&input = YOUR_INPUT_VALUE”,如POSTJSON谢谢。

#6


While using google places api you android api key will not work , create a server key and use that server in in the places url while making request. In manifest your same android api key will lie. This should solve your problem.

使用google places api时你的android api密钥将无效,创建服务器密钥并在提出请求时在地址网址中使用该服务器。在清单中你将使用相同的android api密钥。这应该可以解决您的问题。

#7


I tried this many time util I found the solution

我尝试了很多次,我找到了解决方案

if you will send Url from your app to get place information then you are using Google Places API Web Service not Google Places API for Android

如果您要从应用中发送网址以获取地点信息,那么您使用的是Google Places API网络服务,而不是Google Places API for Android

So you must enable Google Places API Web Service on your API Dashboard and it will work.

因此,您必须在API信息中心上启用Google Places API Web服务,它才能正常运行。

#8


Use Android API is instead of Browser and Server API key. Was facing the same problem but resolved using Android API key.

使用Android API而不是Browser和Server API密钥。面临同样的问题但使用Android API密钥解决了。

#9


Enable "Google Maps Geocoding API" after enable the "Google Maps Android API"

启用“Google Maps Android API”后启用“Google Maps Geocoding API”

#10


Make sure you have 'Google Places API Web Service' enable, and you must use a Server Key (not an Android key)

确保启用了“Google Places API Web服务”,并且必须使用服务器密钥(不是Android密钥)

Google Places API始终返回错误

Google Places API始终返回错误

#11


I solved the problem by enabling Geocoding api in the developer console.

我通过在开发人员控制台中启用Geocoding api解决了这个问题。

#1


I had the same problem. In my case the problem was that I tried to send request using simple HttpUrlconnection by this url:

我有同样的问题。在我的情况下,问题是我试图通过这个url使用简单的HttpUrlconnection发送请求:

 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=62.25227243964484%2C59.12338379770518&radius=500&key=my_key

Where my_key was a key for Google Places API for Android, but when I switched to Google Places API Web Service, this works fine. It seems that for using key for Google Places API for Android you should follow this guide https://developers.google.com/places/android/

my_key是Google Places API for Android的关键,但是当我切换到Google Places API Web服务时,这很好用。对于使用适用于Android的Google Places API的密钥,您应该遵循以下指南https://developers.google.com/places/android/

#2


It looks like you're using the Places API Web Service, which requires enabling "Google Places API Web Service" and providing a server key: https://developers.google.com/places/webservice/intro#Authentication

您似乎正在使用Places API网络服务,该服务需要启用“Google Places API网络服务”并提供服务器密钥:https://developers.google.com/places/webservice/intro#Authentication

Since you're building an Android application, you may want to try the Places API for Android, which we just released in March :) The documentation is available at https://developers.google.com/places/android/

由于您正在构建Android应用程序,因此您可能需要尝试我们刚刚在3月发布的Android版Places API :)该文档位于https://developers.google.com/places/android/

I hope this helps!

我希望这有帮助!

#3


I solved this problem by following below prerequisites:

我通过以下先决条件解决了这个问题:

1) Make sure you are using below URL

1)确保使用以下URL

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=YOURSEARCHTEXT&key=YOUR_SERVER_API_KEY. Don't use your android/IOS API key.

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=YOURSEARCHTEXT&key=YOUR_SERVER_API_KEY。不要使用您的android / IOS API密钥。

2) Make sure you have enabled following API in the console.

2)确保在控制台中启用了以下API。

Google Places API Web Service (Paid Service)

Google Places API网络服务(付费服务)

#4


Actually I was also suffered from this problem but enabling "Google Places API Web Service" worked for me.

实际上我也遇到了这个问题,但启用“Google Places API Web Service”对我有用。

The problem is that we are using Google Places's Web Service for getting Places and we are forget to enable Google Places API Web Service in Google developer console.

问题是我们使用Google商家信息网站服务获取商家信息,但我们忘记在Google开发者控制台中启用Google商家信息API网络服务。

So please make sure that whenever you are using Google Place API and don't forget to enable Google Maps Android API and Google Places API Web Service .

因此,请确保您在使用Google Place API时不要忘记启用Google Maps Android API和Google Places API Web服务。

#5


Make sure Have you enabled Google Places API Web Service. Because Google Places API for Android not for it.
hope it will work.
if not then use a simply url "https://maps.googleapis.com/maps/api/place/autocomplete/json?key=YOUR_API_KEY&components=country:gr&input=YOUR_INPUT_VALUE" like POSTJSON Thank you.

确保您是否启用了Google Places API Web服务。因为适用于Android的Google Places API不适合它。希望它会奏效。如果没有,那么请使用简单的网址“https://maps.googleapis.com/maps/api/place/autocomplete/json?key = YOUR_API_KEY&component / country = gr&input = YOUR_INPUT_VALUE”,如POSTJSON谢谢。

#6


While using google places api you android api key will not work , create a server key and use that server in in the places url while making request. In manifest your same android api key will lie. This should solve your problem.

使用google places api时你的android api密钥将无效,创建服务器密钥并在提出请求时在地址网址中使用该服务器。在清单中你将使用相同的android api密钥。这应该可以解决您的问题。

#7


I tried this many time util I found the solution

我尝试了很多次,我找到了解决方案

if you will send Url from your app to get place information then you are using Google Places API Web Service not Google Places API for Android

如果您要从应用中发送网址以获取地点信息,那么您使用的是Google Places API网络服务,而不是Google Places API for Android

So you must enable Google Places API Web Service on your API Dashboard and it will work.

因此,您必须在API信息中心上启用Google Places API Web服务,它才能正常运行。

#8


Use Android API is instead of Browser and Server API key. Was facing the same problem but resolved using Android API key.

使用Android API而不是Browser和Server API密钥。面临同样的问题但使用Android API密钥解决了。

#9


Enable "Google Maps Geocoding API" after enable the "Google Maps Android API"

启用“Google Maps Android API”后启用“Google Maps Geocoding API”

#10


Make sure you have 'Google Places API Web Service' enable, and you must use a Server Key (not an Android key)

确保启用了“Google Places API Web服务”,并且必须使用服务器密钥(不是Android密钥)

Google Places API始终返回错误

Google Places API始终返回错误

#11


I solved the problem by enabling Geocoding api in the developer console.

我通过在开发人员控制台中启用Geocoding api解决了这个问题。