Google places autocomplete api - REQUEST_DENIED - android

I'm creating app that use autocomplete places google api.
And I don't know what is wrong but all the time I got responses like:
{
"predictions" : [],
"status" : "REQUEST_DENIED"
}
I send req : https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Paris&types=geocode&language=fr&sensor=true&key=mykey
Documentation says :
REQUEST_DENIED indicates that your request was denied, generally because of lack of a sensor parameter.
I have sensor parameter, maybe it is something with api key.
Is there any page where can I get google's log :), to see why I got REQUEST_DENIED?
I use api key from :
http://code.google.com/intl/pl-PL/android/maps-api-signup.html
Maybe I have to get an api key from somewhere else.

You should be able to view your API Key by going to the API Console first:
https://code.google.com/apis/console
If you haven't yet, you will need to create a new "Project" and then enable the Predictions services first by using the On/Off switch.
Please post your results, I have a similar problem with getting the REQUEST_DENIED response, but I've already got the API key and I'm using the sensor parameter like their documentation states.
It is frustrating that Google doesn't give any sort of response code along with REQUEST_DENIED so you can see why it's denying it. This will be difficult to support and troubleshoot in a production environment if this randomly goes out without providing any details as to why.
Update:
I just found this works for me now, but only after changing my requests to GET requests instead of POST. For reasons unknown, Google returns REQUEST_DENIED for POST requests but allows the same request via GET. A quick test for you to see if this is your problem would be to put the URL together with your API key and other parameters and try it through your browser instead. If that works then just rewrite your Android code to use GET instead of POST and you should be all set.

It was solved for me when I exchanged the API key. I was using the one under Android device, I changed it to the one "Key for browser apps (with referers)" and it worked for me although I'm using Android Device.

I recommend using .getJson() to get an error message along with your response to know what is exactly wrong.
For my case in flutter: I used googlePlace!.autocomplete.getJson(value);
and i got the following response.
{ "error_message" : "You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started", "predictions" : [], "status" : "REQUEST_DENIED" }

That's the wrong API key. Follow the steps here to get the right one.

Make sure you API keys are generated correctly and that you have enabled the necessary APIS.
In my case, when designing iOS application - I need to enable Google Maps SDK for iOS, Google Places API for iOS
And most importantly, and without being mentioned by Google (in any other place as well) enable Google Places API Web Service.
With this, I ended a 2 day search for my pesky problem.
And, of course, make sure you use Key for server applications

Related

Android google maps API-key 'REQUEST_DENIED'

I want to use distance matrix by google. When I use postman for checking my URL, it works fine, it returns correct JSON. When I do the same thing in my android app, I receive request denied. I'm not restricitng my key, i do not autorize it, I want it to be public and I want to use it everywhere if possible. There are post 5 years old saying that I might be using web browser Api key, but I cannot find specific, android app manual for android api key generator. What I am doing wrong?
request denied
Another thing, I cannot change anything in my account, but I dont think these options matter since they are optional.
Failed to save
I'm using Retrofit:
#GET("maps/api/distancematrix/json")
Call<DistanceResponseModel> getDistanceModel2(#Query("origins") String origins,
#Query("destinations") String destinations,
#Query("key") String key);
I've activated APi in CloudConsole
i'm adding key to the request
APIs are no restricted or unauthorized
I also added key to manifest and gradle with THIS manual
I was using http instead of https in my serivce generator. So yeah, lol.

unable to get the routes from the google api

I got the api key by following the usual steps.
Then I was able to get map and use some inbuilt things on it like search etc
Then later I tried routing, I was unable to get the routes. When I pasted the request:
https://maps.googleapis.com/maps/api/directions/json?origin=28.6100,2077.2300&destination=18.9750,72.8258&key=mykey
on the browser I got the following and realized that I don't have the permission. I searched for this problem but couldn't find the solution, please help.
Response on browser:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address xxxxxxxx, with empty referer",
"routes" : [],
"status" : "REQUEST_DENIED"
}
Make sure you are using server API key, not an Android key (mobile development). See this post:
Google Places API request denied for Android autocomplete, even with the right api key .
Also make sure you are sending the key to GooglePlaces instance.
If you are restricting use of API key by IP make sure your request is coming from an allowed address.

What Is The Difference Between Google+ APIs and Google+ Domain APIs?

I am a little confused by these APIs. I am trying to integrate Google+ with my Android app and I am struggling a little. I have been successful at logging in a user using OAuth2, created a Verifier, obtained an accessToken and made a request to Google+ API.
Here is my line of code requesting to see the user information:
OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/plus/v1/people/me");
This successfully returns a jSON object containing my information/public.
Whenever I change the endpoint to this:
"https://www.googleapis.com/plusDomains/v1/circles/p4643b3a289c42c44"
attempting to use the PlusDomains, I get a forbidden message.
What I really want to do is manage circles for a user (simply add a page to their "Following" circle. That is all I need.
What am I doing wrong? Am I trying to use the wrong endpoint? Does Google+ API allow me to do POST requests?
Every piece of information is helpful.
Thanks in advance!
Google+API and Google+Domains API are different APIs (activating/allowing one does not activate/allow the other).
The Domains API can be considered as a more powerfull (more functionnalities) than Google+API.
See comparison of the two API here on the official doc.
Link here

When I was using google place api, I got an OVER_QUERY_LIMIT, but I only sent 3 times in last 24 hours

I'm using google place api to develop a mobile application.
The Http request I sent was:
https://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=true&key=KEY&components=country:uk&input=hu
But when I sent HTTP request to the Google server, it replies OVER_QUERY_LIMIT:
{
"predictions" : [],
"status" : "OVER_QUERY_LIMIT"
}
I have checked the instruction provided by Google and Android document, and also I have checked the usage of the requests from reports in the Google Console. But I found the used request is only 3, and the request/sec is 0.0017.
Could anyone provide some help on it? Thanks very much!
Oh...I have fixed up my error.
The reason was that I was using a public-shared API_Key by mistake, so sometimes I could get the result, but sometimes couldn't.

Google Places API autocomplete - REQUEST_DENIED

I'm having a difficult time getting a valid autocomplete response from the Google Places API. I'm using code based on [their example}(https://developers.google.com/places/training/autocomplete-android) (which, interestingly is using a seemingly invalid country code of "uk").
I have enabled Places API in my Google Code Console.
My API key was generated when I first enabled the Maps API a couple of weeks ago, and the MapFragment I'm using is working perfectly, so I have no reason to suspect that the API key is invalid.
The URL I'm using is https://maps.googleapis.com/maps/api/place/autocomplete/json?input=New+York&sensor=false&key=my_valid_api_key&components=country:us
I always get {"status":"REQUEST_DENIED","predictions":[]} as my response.
I have verified multiple times that my url is formed correctly and adheres to the requirements of the Places API autocomplete endpoint, yet I do not get the response I'm expecting.
I have seen a number of suggestions of how to fix this on SO and elsewhere, but none of them have worked for me (i.e.-using http instead of https, use port 443, etc.) I have tried these in all reasonable combinations with no change in the response.
Please help me find what I'm doing wrong.
I tried the URL you provided with my key and it returned the expected results. I suspect you are using an Android key instead of a Browser key. Try creating and using a Browser key (under "Simple API Access").
Use the server or browser key instead of the iOS key. Keep the refers field blank to allow all refers.
Here is a sample project which does the same :https://github.com/manishnath/Autocomplete
Try this way https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Aus&types=geocode&language=eng&key=your_APIKEY
also refer this like
http://codetheory.in/google-place-api-autocomplete-service-in-android-application/
REQUEST_DENIED indicates that your request was denied, generally because of lack of a sensor parameter.try this
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=geocode&language=fr&sensor=true&key=AddYourOwnKeyHere

Categories

Resources