Google地图:平台拒绝了您的请求。此I [...]网站或[...]无权使用此API密钥

时间:2018-05-25 22:11:39

标签: api maps embed

<iframe width="100%" height="427" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=place_id:[place_id]&key=[my_key]" allowfullscreen></iframe>

&#34; Google Maps Platform拒绝了您的请求。此IP,站点或移动应用程序无权使用此API密钥。从IP地址xxx.xxx.xxx.xxx收到的请求,请参阅:https://xxx.xxx/&#34;

在Google Dev中,我启用了Maps Embed API和Maps Static API。我限制了仅使用我的域名的密钥,其中包含上述代码,例如https://[asterisk].thedomain.com/[asterisk]

当我不限制此单个域的密钥时,地图嵌入工作并且不会抛出错误。

问题是,密钥在代码中是可读的,因此我需要将密钥限制在我的域中。

有什么想法吗?

谢谢。

3 个答案:

答案 0 :(得分:3)

我的相关网站的投放方式类似于https://thedomain.com/

Google Maps Platform确实在https://www.thedomain.com/https://thedomain.com/之间有所不同。

将我的API限制为https://thedomain.com/*对我有用,而https://*.thedomain.com/*并不意味着*一无是处。

答案 1 :(得分:0)

确保已在要使用的API密钥的密钥限制/ api限制部分添加了“ Maps Embeded API”。

答案 2 :(得分:0)

如果您查看了google提供的示例,则为错误。它应该是:http:// example.com/ 而不是http:// .example.com / ,因为如果有一个点,它将不起作用您的域名前不能有一些东西,例如www。

http://example.com不能仅仅因为它没有“。”而不能工作。在//和示例之间。