Question

I'm using the Google map v2 for android. I would like to call to the directions api to get the points from android device. I registered the Google console key, I can view the map on android. I used this key to include in the directions api call like this:

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false&key=API_KEY

The API_KEY is the key I created for maps:

api key for maps and directions

But when I request from android apps to call to directions api, I got this returned:

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

How can I resolve this error? Please help

Thanks

Was it helpful?

Solution

this is right URL which is call to get direction path between two geo point.

http://maps.googleapis.com/maps/api/directions/json?origin=23%C2%B0%201%27%2050.49711640%22%2C%2072%C2%B0%2034%27%2014.520786762%22&destination=22%C2%B0%2017%27%208.23132830%22%2C%2073%C2%B0%2012%27%2026.766651630%22&sensor=true&mode=driving

there is no need to pass KEY=api-key in Direction URL..

so,please remove this paramter.and call URL As per above.. api key only put in <meta-data> tag in manifest file.

Please call this URL:

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false

i hope its useful to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top