且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Google Maps JavaScript API v3 for Work UnauthorizedURLforClientIdMapError

更新时间:2023-02-14 13:08:30

使用Google Maps for Work和ClientID的每个网址必须经过授权才能使用clientid。



您可以找到所有详情这里。但这是总结:



  • 域名或IP地址不一定要公开访问 li>
  • 指定域的所有子域也都是授权的。

  • 授权路径的所有子路径也都是授权的。 >路径区分大小写。

  • 您可以限制使用特定端口的URL。

  • HTTP和HTTPS协议被视为不同的URL。 li>

如果您收到 UnauthorizedURLForClientIdMapError ,请查看URL授权规则并看看你是否只需要将URL添加到授权URL列表。



顺便说一句,这里是 Google Maps API错误代码和解释。


I'm using Google Maps Web Services API for work, and they've given me a client ID. When I load up the main page, I don't get an error. However, when I click a sub-page, eg localhost:8080/pages/page.xhtml, I get an error called UnauthorizedURLforClientIdMapError, with the message that this URL is not authorized to use the provided Google Maps client ID.

For reference, Google discusses it in its documentation here: https://developers.google.com/maps/documentation/business/clientside/auth#registering_authorized_urls

With all that being said, I'm currently testing my server with TomCat using the URL http://localhost:8080. This domain has been authorized, as has my individual IP. In my view files, I'm adding this:

<script src="https://maps.googleapis.com/maps/api/js?    &amp;client=MY_CLIENT_ID
        &amp;v=3.19
        &amp;channel=MY_CHANNEL" type="text/javascript"></script>

where 'MY_CLIENT_ID' and 'MY_CHANNEL' are obviously changed to suit my needs (my client id and channel are correct). I've searched through stack overflow and also read all of the relevant Google Documentation but I feel like I'm missing something very small (or large, I'd hope not though).

What's going on?

Each URL that uses Google Maps for Work with the ClientID must be authorized to use that clientid.

You can find all the details here. But this is the summary:

  • The domain name or IP address does not have to be publicly accessible
  • All subdomains of a specified domain are also authorized.
  • All subpaths of an authorized path are also authorized.
  • Paths are case sensitive.
  • You may restrict valid URLs to those using certain ports.
  • HTTP and HTTPS protocols are considered different URLs.

If you are getting the UnauthorizedURLForClientIdMapError, look through the URL authorization rules and see if you simply need to add the URL to the list of authorized URLs.

Btw, here is the the list of Google Maps API Error Codes with explanations.