Google Map error: InvalidKeyOrUnauthorizedURLMapError

I am developing in JavaScript/HTML/CSS an app that uses Google Maps. I am getting the following alert dialog box:

"This page was unable to display a Google Maps element. The provided Google API key is invalid or this site is not authorized to use it. Error Code: InvalidKeyOrUnauthorizedURLMapError"

The app does actually display the map element; the alert is not a problem except it should not appear at all. The map displays properly.

I have gone in to the Google Developer's Console and, in the "Credentials" section, have "edited allowed referrers" to be*

I have also gone in to the Google Developer's Console in the APIs section and enabled 11 Google Maps APIs.



After lots of referrer combinations, deleting and re-creating credentials i realized that i didn't enabled "Google Maps JavaScript API". What a shame. :)

For anyone who is having trouble to get google maps api work please check if the API enabled first.


After struggling a lot with this issue I've found 1 solution for me. It might help people who are searching for a proper and exact solution but not the comments, downvotes and links.
(Map was not displayed in my case.)

If suppose,the link of page where you are loading map is

then give thesame(exactly the same) under Edit allowed references

If you try loading the same page using:


then your page is loaded but not your map, and this alert is generated.


Use the same path(Url address) at these 2 places.

  1. While loading the page which has map.

  2. Under Edit allowed references.

After following this I've got rid from this alert.


First you need to go to and select APIs.

In Google Maps APIs select Google Maps JavaScript API and make sure you enable API for Google Maps JavaScript.

Secondly, you need to create an API key:

  1. Go to Credentials
  2. Create new key and select Browser Key
  3. No need to specify any referrers

So you should see Any referrer allowed after you save.


After a lot of trial and error this worked for me (by Eduardo. Thanks !)

The URL that needs to be authorized is the one in the Referrer header for the requests the browser sends to Google to load the API.

Under Browser Credentials > REFERERS

Add these


geocodezip provided the info i needed. I was indeed loading the googlemaps library twice: once in my index.html file and once in an iFrame. I changed my code so that the iFrame did not load the googlemaps library but, instead, used the parent. Thanks geocodezip!


Go to APIs menu and find "Google Maps JavaScript API" after you open it just press "Enable API"


I was able to get this to work by deleting all my referrers and allowing all. Apparently there is a bug in the developer console that is causing problems. Some people say that they can get referrers to work by deleting all then adding all back in at once instead of line by line:!topic/maps/mSVyDazRMQo

Previous things I tried:

  1. Regenerating Key
  2. Setting all maps apis to enabled
  3. Hard coding absolute paths of referrers

A side note, when I didn't include my api_key everything worked fined, though I'm sure they will eventually turn you off if you don't use your api_key.


What worked for me was to use Firebug in order to find the exact URL that made the request to the Google Maps API. As stated in Google Maps API documentation on troubleshooting authorization, "How to find the correct URL" part:

The URL that needs to be authorized is the one in the Referrer header for the requests the browser sends to Google to load the API.

In my case, lets suppose I have a website In the developer console, under Google Maps API key, I've added many combinations of referrer such as*, **,, but still the InvalidKeyOrUnauthorizedURLMapError persisted.

My solution, as I've mentioned, to use Firebug: open and look for what was the referrer making request to, and it was, and that is it. I've added* to the enabled URLs in the Developers Console under my respective API key and now everything works fine.

It is important to know where to look for on Firebug: it is the Net tab. Just click on the request to maps.googleapis ... and look for the Referer


I got it to work by exchanging the keys with my own special created keys AND reading this webpage a few times very carefully. My advice is to add or exchange your Google API Keys at before embarking in very complicated scripting.

Insert your own API keys in the very first line of the Google Map javascript:


If you have been setup all configuration like api key etc, and you still got the error, please enable all your mandatory APIs regarding to google maps.


Google Maps Embed API
Google Maps Geocoding API
Google Maps Geolocation API
Google Maps JavaScript API


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.