change world
change world

Reputation: 63

Directions and API key

I want to use direction between two point (routing on map) with using google map api v2. I should write a URL and send to server like this : "http://maps.googleapis.com/maps/api/directions/json"+origin+destination+apiKey.

In android site, said should to send apiKey and in some questions in stackoverflow or some tutorial not add apiKey to URL. Now i am confused, i don't know should send api key or not. when i add debug api key(that writes in manifest file) , result sent, had error--

This IP, site or mobile application is not authorized to use this API key.

and when i did not add api key,i had another error.

Please explain for me, i should add api key or not? And should i add Google maps Geolocation API to my console for using directions?

Thanks for your answers ;)

Upvotes: 0

Views: 3917

Answers (2)

Takumi
Takumi

Reputation: 67

If your GoogleMaps API key is unrestricted in the console, it works.

I had problems("...not authorized to use this API key") when I restricted that key by Android Package ID .

Finally I created an IP address restricted key(my router public IP) for local test inside my LAN.

I think that in production environment, the mobile app that needs to use the Directions API, should be thought an web server with an IP restricted key.

If you don't care the security implications to use an unrestricted API key, you can choose: 1.- Use an unrestricted API key for both, Maps and Directions API. 2.- Use an Android restricted key for Maps and an unrestricted key for Directions.

In my opinion, the Directions API is not yet integrated in Android SDK.

For detailed info: https://developers.google.com/maps/documentation/directions/get-api-key#get-an-api-key

Upvotes: 2

Pierre
Pierre

Reputation: 17407

You should use the API Key, but the API Key you have created for your project in the developer console (in APIs & Auth > Credentials) and enable it for your application. Make sure you also enable the Directions API (or whichever API you're using) in "APIs & Auth > APIs".

Upvotes: 0

Related Questions