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.
我正在使用Google Maps Web Services API工作,他们给了我一个客户端ID。当我加载主页面时,我没有收到错误。但是,当我单击子页面时,例如localhost:8080 / pages / page.xhtml,我收到一个名为UnauthorizedURLforClientIdMapError的错误,并显示此URL未被授权使用提供的Google Maps客户端ID的消息。
For reference, Google discusses it in its documentation here: https://developers.google.com/maps/documentation/business/clientside/auth#registering_authorized_urls
作为参考,Google在其文档中对此进行了讨论: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:
尽管如此,我目前正在使用URL http:// localhost:8080使用TomCat测试我的服务器。此域名已获得授权,我的个人IP也已获得授权。在我的视图文件中,我添加了这个:
<script src="https://maps.googleapis.com/maps/api/js? &client=MY_CLIENT_ID
&v=3.19
&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).
其中'MY_CLIENT_ID'和'MY_CHANNEL'明显改变以适应我的需要(我的客户ID和频道是正确的)。我已经搜索了堆栈溢出并且还阅读了所有相关的Google文档,但我觉得我错过了一些非常小的东西(或者很大,我希望不会这样)。
What's going on?
这是怎么回事?
2 个解决方案
#1
Each URL that uses Google Maps for Work with the ClientID must be authorized to use that clientid.
必须授权使用带有ClientID的Google Maps for Work的每个URL使用该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
域名或IP地址不必公开访问
- 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.
您可以将有效URL限制为使用某些端口的URL。
- HTTP and HTTPS protocols are considered different URLs.
HTTP和HTTPS协议被视为不同的URL。
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.
如果您收到UnauthorizedURLForClientIdMapError,请查看URL授权规则,看看您是否只需要将URL添加到授权URL列表中。
Btw, here is the the list of Google Maps API Error Codes with explanations.
顺便说一下,这是Google Maps API错误代码列表及其解释。
#2
You must allow the referred URLs related to that Client ID in the Google support management portal.
您必须在Google支持管理门户中允许与该客户端ID相关的引用URL。
Access to the Google Support Management portal - http://www.google.com/enterprise/portal - , login with your enterprise google account, then in the left menu, go to "Maps, Manage Client ID" link, select you client id in the combo, and in the "Enter the URLs" textarea, write the referrer URL you want to authorize and click on "Add URL" button.
访问Google支持管理门户网站 - http://www.google.com/enterprise/portal - ,使用您的企业级Google帐户登录,然后在左侧菜单中,转到“地图,管理客户端ID”链接,选择您的客户端在组合中的ID,在“输入网址”textarea中,写下您要授权的引荐来源网址,然后点击“添加网址”按钮。
If you are using a ClientID instead an API KEY to authenticate to Google Maps services, the referrer URLs must be authorized here. If you are using an API KEY, yo must authorize the referrer urls from the google developers console.
如果您使用ClientID而不是API KEY对Google地图服务进行身份验证,则必须在此处授权引荐来源网址。如果您使用的是API KEY,则必须从google开发者控制台授权引荐来源网址。
#1
Each URL that uses Google Maps for Work with the ClientID must be authorized to use that clientid.
必须授权使用带有ClientID的Google Maps for Work的每个URL使用该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
域名或IP地址不必公开访问
- 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.
您可以将有效URL限制为使用某些端口的URL。
- HTTP and HTTPS protocols are considered different URLs.
HTTP和HTTPS协议被视为不同的URL。
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.
如果您收到UnauthorizedURLForClientIdMapError,请查看URL授权规则,看看您是否只需要将URL添加到授权URL列表中。
Btw, here is the the list of Google Maps API Error Codes with explanations.
顺便说一下,这是Google Maps API错误代码列表及其解释。
#2
You must allow the referred URLs related to that Client ID in the Google support management portal.
您必须在Google支持管理门户中允许与该客户端ID相关的引用URL。
Access to the Google Support Management portal - http://www.google.com/enterprise/portal - , login with your enterprise google account, then in the left menu, go to "Maps, Manage Client ID" link, select you client id in the combo, and in the "Enter the URLs" textarea, write the referrer URL you want to authorize and click on "Add URL" button.
访问Google支持管理门户网站 - http://www.google.com/enterprise/portal - ,使用您的企业级Google帐户登录,然后在左侧菜单中,转到“地图,管理客户端ID”链接,选择您的客户端在组合中的ID,在“输入网址”textarea中,写下您要授权的引荐来源网址,然后点击“添加网址”按钮。
If you are using a ClientID instead an API KEY to authenticate to Google Maps services, the referrer URLs must be authorized here. If you are using an API KEY, yo must authorize the referrer urls from the google developers console.
如果您使用ClientID而不是API KEY对Google地图服务进行身份验证,则必须在此处授权引荐来源网址。如果您使用的是API KEY,则必须从google开发者控制台授权引荐来源网址。