简体   繁体   English

Google Maps API密钥-网址限制

[英]Google Maps API Key - URL Restrictions

A few days ago i generated an API Key to embed Google Maps in my projects. 几天前,我生成了一个API密钥,可将Google Maps嵌入到我的项目中。 It works pretty well, because i made no restrictions - so basically everyone could have used the key. 它工作得很好,因为我没有任何限制-基本上每个人都可以使用该密钥。

Today i tried to make some restrictions, based on my domain - but i have a couple of problems: 今天,我尝试根据自己的域设置一些限制-但我遇到了两个问题:

Absolute URLs with URI works pretty fine - eg . 带有URI的绝对URL可以正常工作-例如

http://example.com/myFirstTest.html

or 要么

http://example.com/mySecondTest.html

Google allows schema restriction like: Google允许架构限制,例如:

*example.com/*

which i have tried without any success, because the Maps API responds with " RefererNotAllowedMapError " which references to my only restriction i made? 我尝试过但没有成功的原因,因为Maps API会以“ RefererNotAllowedMapError ”作为响应,该引用引用了我所做的唯一限制?

I also tried another absolute URL without any URI / Parameter: 我还尝试了另一个没有任何URI /参数的绝对URL:

example.com/*

and

example.com/

again - without any success. 再次-没有任何成功。

A wildcard pattern isn't working either: 通配符模式也不起作用:

example.com/*.html

or 要么

*example.com/*.html

Please let me know, if you need more informations! 如果您需要更多信息,请告诉我!

I noticed you mentioned trying 我注意到你提到尝试

*example.com/*

Have you tried something like this instead? 您是否尝试过类似的方法?

*.example.com/*

I used an API key of my own and JSBin to test this out. 我使用自己的API密钥和JSBin对此进行了测试。 If I just authorize: 如果我只是授权:

jsbin.com/*

I get an error, but it works fine if I authorize: 我收到一个错误,但是如果我授权,它可以正常工作:

*.jsbin.com/*

I'd recommend trying to authorize like my example directly above, making sure you have a wildcard for any subdomains or subpaths. 我建议尝试像上面的示例一样授权,以确保您对所有子域或子路径都具有通配符。

I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM