22

I am getting the error RefererNotAllowedMapError from some PC's when I load a page on my site.

RefererNotAllowedMapError

The current URL loading the Google Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key on Google Cloud Console.

See API keys

It works OK on FireFox from 3 out of four of the machines I have tested.

Generally this would mean that the domain is not added as a referer in my API console but it definitely is, and it definitely works on other machines.

Anyone else had this issue or able to provide some guidence?

bwash70
  • 1,135
  • 2
  • 11
  • 24
  • I have the same problem with my web client for a rest api using a google map. for me only firefox has a problem with showing the map and shows me an ""RefererNotAllowedMapError: https://developers.google.com/console/help/new/#apikeybestpractices"" error - anyone any idea how to solve this? – Freddy Sep 17 '15 at 21:32
  • I recreated by API key and it started working again across all browsers. – bwash70 Sep 19 '15 at 05:54
  • @Freddy same happen with me,,,only firefox show this message, even i allow the domain. – Hamza Zafeer Jul 18 '16 at 14:44

9 Answers9

20

Recreating the API key at console.developers.google.com fixed the issue for me.

Samuel Lapointe
  • 305
  • 3
  • 13
bwash70
  • 1,135
  • 2
  • 11
  • 24
11

Try to add all type of urls like:

http://stackoverflow.com/*

http://www.stackoverflow.com/*

*.stackoverflow.com/*

Definitely it will work.

Bunty
  • 1,549
  • 13
  • 18
3

Note the DOT at the beginning of the expression, it's a char!

*.stackoverflow.com/* // this will not work with http://stackoverflow.com and will allow for domains such as demo.stackoverflow.com

Replace above with:

*://stackoverflow.com/* // now it will cover all domain variation but not subdomains.

DevWL
  • 17,345
  • 6
  • 90
  • 86
  • 2
    Which would allow http://notstackoverflow.com to use your API key. So not a good idea. – Gregoire D. Feb 02 '18 at 11:05
  • Note that `*.stackoverflow.com/*` also allow `not.stackoverflow.com` to use API. What is more important that the "dot" char will not allow API to be used by `http://stackoverflow.com` – DevWL Apr 06 '18 at 00:12
  • @GregoireD. This is not true as it is a "." char and not a regex placeholder for any char. So it would allow for subdomains but disallow main domain. This is why you need to add *://stackoverflow.com/* in addition or instead, depending on if you want to include subdomains or not. – DevWL Jun 13 '22 at 01:02
2

For me to use Places API I had to turn on Maps JavaScript API

jean d'arme
  • 4,033
  • 6
  • 35
  • 70
  • 1
    Thanks for sharing this! This is super cryptic.. When I went through the API list, I couldn't find "Maps Javascript API", but apparently there's a separate page where I have to go and enable the API before it'd show up... I spent 30 mins figuring this out.. – BlackSoil Aug 29 '19 at 10:34
1

This gives error because your Google map API key is not a browser key. Create new key as 'browser key'. This option is available when you create a new key.

R.evolvan
  • 91
  • 1
  • 1
  • 4
1

I had a similar issue where I was trying to use the API but had it restricted to Map product only. It generated the same error even though http referrer box had nothing in it (open for all). The problem went away after recreating a new key without any product restriction.

Mir3
  • 93
  • 2
  • 7
0

Creating an new Browser Key fixed it for me. https://console.developers.google.com/projectselector/apis/credentials

RefererNotAllowedMapError Error The current URL loading the Google Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key on the Google API Console.

See API keys in the Google API Console. For more information, see Best practices for securely using API keys.

Sarat Chandra
  • 5,636
  • 34
  • 30
0

The only thing that worked for me was to create a brand new key w/no restrictions, including no API restrictions.

This won't be a working solution in the production environment, but it allows us to move ahead w/development.

Dr. Hilarius
  • 1,134
  • 1
  • 14
  • 20
0

The solution to every/such Maps Javascript API error varies for different scenarios for different developers. A list of errors with detailed description is given by google here

Nevertheless please refer the below snap: Maps Javascript API restrictions

  1. As you can see above under Application restrictions just by selecting the HTTP referrers won't do. You have to add a URL(i.e the URL of the website from which the api will be called to render the map).
  2. Now the exact page(in my case the contact us page) which is gonna make the request to the api needs to be mentioned in the url and not just the domain.
  3. Please go through the examples given in the documentation on the right
  4. Adding a /* after the domain url like http://www.telesuprecon.com/* will make the request possible from any page within your website.
Tahir77667
  • 2,290
  • 20
  • 16