首页 > javascript > Google maps premium - 为什么 - “Google Maps JavaScript API不需要签名参数”

Google maps premium - 为什么 - “Google Maps JavaScript API不需要签名参数” (Google maps premium - Why - “The signature parameter is not required for the Google Maps JavaS)

问题

我正在迁移我的地图以使用高级计划并按照说明操作:

https://developers.google.com/maps/documentation/static-maps/get-api-key(这些是针对静态地图的,但我认为同样适用于其他api)

段落 - 生成用于客户端ID的数字签名

我能够为我的脚本结果生成数字签名,例如:

<script src="https://maps.googleapis.com/maps/api/js?&client=clientID&channel=qa&signature=signature"></script>

它有效,但我收到一个警告,说签名没有被要求,确实没有签名。

显然我需要静态地图和方向的签名,为什么这不适用于标准api?

我试图找到一份完整的apis列表,我需要签名,而我不需要签名,但是可以使用。有人能给出一个线索吗?

解决方法

您不需要Google Maps JavaScript API的签名参数,因为您的客户端ID已受到您可以在Cloud Support门户中管理的允许的URL /域列表的保护。

您可以在以下文档中阅读有关客户ID的URL授权:https//developers.google.com/maps/documentation/javascript/get-api-key#registering-authorized-urls

如果是静态地图或Web服务(地理编码API,Directions API等),您没有任何类型的每个URL保护,因此您必须生成数字签名,以保护您的客户端ID免遭未经授权的使用。

有关Premium计划中的身份验证和授权的更多详细信息,请查看

https://developers.google.com/maps/premium/overview#authentication-and-authorization

我希望这有帮助!

问题

I was migrating my maps to use the premium plan and followed the instructions:

https://developers.google.com/maps/documentation/static-maps/get-api-key (these are for the static maps, but I believed same applies for other apis)

Paragraph - Generating a digital signature to use with client IDs

I was able to generated a digital signature for my script result in something like:

<script src="https://maps.googleapis.com/maps/api/js?&client=clientID&channel=qa&signature=signature"></script>

It works but I receive a warning saying that the signature is not requied and indeed it works without a signature.

Apparently I need a signature for staticmaps and directions, so why does this not apply for standard apis?

I was trying to find a full list of apis for which I need a signature and for which I don't, but to avail. Can someone give a clue, please?

解决方法

You don't need the signature parameter for Google Maps JavaScript API because your client ID is already protected by the list of allowed URLs/domains that you can manage in the Cloud Support portal.

You can read about URLs authorization for client IDs in the following document: https://developers.google.com/maps/documentation/javascript/get-api-key#registering-authorized-urls

In case of static maps or web services (Geocoding API, Directions API, etc.) you don't have any kind of per URL protection, so you have to generate a digital signature in order to protect your client ID from unauthorized use.

For further details about authentication and authorization in Premium plan take a look at

https://developers.google.com/maps/premium/overview#authentication-and-authorization

I hope this helps!

相似信息