Google maps API referrer not allowed

2020-02-06 04:58发布

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?

9条回答
贼婆χ
2楼-- · 2020-02-06 05:38

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

查看更多
贪生不怕死
3楼-- · 2020-02-06 05:38

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.
查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-02-06 05:41

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.

查看更多
Bombasti
5楼-- · 2020-02-06 05:50

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.

查看更多
家丑人穷心不美
6楼-- · 2020-02-06 05:52

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

*.stackoverflow.com/* // this will not work with http://stackoverflow.com

You will also have to add:

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

查看更多
【Aperson】
7楼-- · 2020-02-06 05:53

Try to add all type of urls like:

http://stackoverflow.com/*

http://www.stackoverflow.com/*

*.stackoverflow.com/*

Definitely it will work.

查看更多
登录 后发表回答