Search code examples
google-mapsgoogle-maps-api-3api-keygoogle-geocoding-apigeocode

Restricted Google API key is not working in Reverse Geocoding


I have develop an iPhone Application that have Google Api https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&key=API_KEY

if I have use Public apikey then its working fine but when I generate ristricted api key from google concole then api is not working and give error

    {
   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 27.109.**.**, with empty referer",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

I have added valid bundle Id when I generate restricted Api key. please give me solution Thanks in advance.


Solution

  • You are calling a web service (Geocoding API). Please note that web services support only IP address restriction. The iOS app restriction is not valid for web services, it works only with Google Maps SDK for iOS. You can find information about restrictions supported by each API in this document:

    https://developers.google.com/maps/faq#keysystem

    In order to use a restricted API key with Geocoding API from iOS app you will need to create your own intermediate server and execute calls to Google from your server. In this case you can protect an API key with IP address of your server. The app will request information from your server and you server will call Google and pass back results.