Guess
Guess

Reputation: 238

Google Places API always return error

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

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

{"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 -

{
 "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 - enter image description here

Upvotes: 12

Views: 21499

Answers (11)

Megha
Megha

Reputation: 41

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

Upvotes: 0

SolArabehety
SolArabehety

Reputation: 8616

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

Enable api

set credential

Upvotes: 0

Mohamed Fadel Buffon
Mohamed Fadel Buffon

Reputation: 636

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

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

Upvotes: 1

Imeshke
Imeshke

Reputation: 821

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

Upvotes: 0

KishuDroid
KishuDroid

Reputation: 5451

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

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.

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 .

Upvotes: 2

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.

Upvotes: 1

Dalvinder Singh
Dalvinder Singh

Reputation: 1083

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.

Upvotes: 1

Smeet
Smeet

Reputation: 4126

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

Upvotes: 0

Shoaib Chikate
Shoaib Chikate

Reputation: 8973

I solved this problem by following below prerequisites:

1) Make sure you are using below 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.

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

Google Places API Web Service (Paid Service)

Upvotes: 2

Mikhail Valuyskiy
Mikhail Valuyskiy

Reputation: 1298

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

 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/

Upvotes: 18

Francois Wouts
Francois Wouts

Reputation: 3962

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

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/

I hope this helps!

Upvotes: 9

Related Questions