Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Key Restrictions by IP Address not working

I am trying to restrict access to my Google Maps API account by using IP Address to set up Key Restriction. Previously I have been able to set up Key Restriction using the HTTP Referrer, but I do not seem to be able to get the same config happening using IP Addresses. I have generated a new key to use with the IP Addresses (leaving the current using HTTP Referrer in play as it works).

As an example I can access the MAPS API from localhost/* but am unable to access it from 127.0.0.1 (using the new API key with AP Address key restrictions setup). My actual website is hosted on a shared sever and using the domain name (perfectpets.com.au) with the HTTP referrer restriction all is good, but if I use the new API key with IP address restriction I get the RefererNotAllowedMapError error.

Any tips on how to get this going would be greatly appreciated.

like image 210
John McInnes Avatar asked Jan 07 '18 05:01

John McInnes


People also ask

Why is my Google Maps API key not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.


1 Answers

IP address restrictions only work for web services, not the Google Maps JavaScript API v3.

From the documentation

Once restricted, a key will only work on platforms that support that type of restriction.

  • IP addresses (individual servers) - for use with the web service APIs.
  • HTTP referrers (web sites) - for use with the Web APIs.
like image 74
geocodezip Avatar answered Sep 23 '22 14:09

geocodezip