1

I am using Geocoder to get address from latlng. But as my requests will be more such as 300 latlng for a minute. Google was returning "Service Not Available Exception".

I was suggested to use Geocoding Api "https://maps.googleapis.com/maps/api/geocode/json?latlng=&language=&key=API_KEY".

I have used this but I was getting "This IP, site or mobile application is not authorized to use this API key".

Api key is from Android App with package and SHA1 restrictions. I have searched all documentation and got to know that Android Api key with restrictions will not work for Webservice Api i.e, Geocoding APi

Later I have tried an approach replacing my API key with SERVER KEY. Everything is working fine. But here comes the issue.

SERVER KEY can be restricted only from websites or webservers or with ip address. But I am using this in Andorid App. So my key is not secured and can be misused.

I have checked all google platform site and all FAQ's https://developers.google.com/maps/api-key-best-practices#independent_apikey .I have not got any answer and got to know that Webservice Api's are only for Websites.

I don't want to use it using webserver and need only from android app. I need to secure my SERVER KEY from android app. Or is there any way that Android APi key will work.

Struck with this issue from one week.

Any Help..Thanks in advance

  • Android API key won't work with web services. The only possible way is creating an intermediate proxy server to send requests from this server to Google with protected API key (by IP address) and pass results back to your app. So your app sends request to proxy, proxy sends request to Google with protected key and return results to app. – xomena Jun 15 '20 at 19:25
  • Yes I have checked this about using proxy server .But my doubt is if we use this approach the time taken to fetch data or address from proxy will increase compared to directly calling Webservice Api. And one more thing if we are not able to use this Android APi key and also geocoder class is not giving expected results then what is use Geocoder class. – Anusha_madhineni Jun 16 '20 at 05:02
  • You can also think about caching results on your proxy in order to improve response time. Google allows temporary cache geocoding results for 30 days. So you can cache data and refresh cache every 30 days. – xomena Jun 16 '20 at 08:29
  • Thank you so much @xomena for your answers. One more quick question how we will authenticate proxy url to only for our android app. And the Api key we use for proxy is SERVER KEY right and we should add restriction to it using only ip address. So what is the security of that from android. Any one who has proxy url can misuse it if there is no authentication .Is there any restriction for this. – Anusha_madhineni Jun 16 '20 at 10:14
  • I am referring to this proxy using Google maps [link] (https://codelabs.developers.google.com/codelabs/google-maps-web-services-proxy/index.html?index=..%2F..%2Findex#3) – Anusha_madhineni Jun 16 '20 at 10:28

0 Answers0