Alex Christodoulou
Alex Christodoulou

Reputation: 2963

Google Places REQUEST_DENIED from Server Request - Nothing works

After hours of searching and trying every possible solution found on the web, I cannot try anything else for my problem, so I really need help:

I want to implement a simple autocomplete text box with geocode results, so I call AJAX requests while the user types in the text box

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=MY_SEARCH_STRING&language=us&types=geocode&sensor=false&key=MY_KEY

where MY_SEARCH_STRING is a simple string like "London" and MY_KEY the Key I have created

{ "predictions" : [], "status" : "REQUEST_DENIED" }

I appreciate a lot any help!! Thank you.

Upvotes: 2

Views: 1993

Answers (3)

sdrubish
sdrubish

Reputation: 199

I've had a similar issue, fixed it and discovered a few things that may be useful in troubleshooting this

  • using http instead of https will result in REQUEST_DENIED
  • omitting &userIp=x.x.x.x will result in REQUEST_DENIED
  • a server key needs to be generated and used in case the request is from a php script even if ONLY consumed via browser by users or it will result in REQUEST_DENIED
  • a few minutes are necessary before testing if the list of IPs allowed has been changed

Hope it helps some of you guys

Upvotes: 1

Alex Christodoulou
Alex Christodoulou

Reputation: 2963

SOLVED. In Google API Console, I had declared allowed server IPs. I was assuming that if I declared an IP, I was just ensuring that requests would be allowed only from that IP. In order for this to work, you must also declare the allowed per-user limits for each IP, or else it just doesn't allow any requests. I removed all the allowed IPs, waited for 3-4 minutes, and the request was allowed.

Upvotes: 5

Themos Piperakis
Themos Piperakis

Reputation: 675

Not sure if this helps, but here is a short example:

https://google-developers.appspot.com/maps/documentation/javascript/examples/places-autocomplete?hl=el

Upvotes: 1

Related Questions