此 IP、站点或移动应用程序无权使用此 API 密钥

编程入门 行业动态 更新时间:2024-10-27 18:26:26
本文介绍了此 IP、站点或移动应用程序无权使用此 API 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 https://maps.googleapis/maps/api/geocode/json?与服务器密钥和用户 IP 链接以查找任何地址的纬度和经度,当我尝试时发现错误为

I am using https://maps.googleapis/maps/api/geocode/json? link with server key and user IP to find the latitude and longitude of any address, when I'm trying I find the error as

我有一个来自 google 的服务器访问密钥,并且我已经将我服务器的 IP 地址放在了他们的白名单中.

I have a server access key from google and I have put my server's IP address in the their white list.

我试图通过 PHP CURL 访问的 URL 是:

The URL that I am trying to access via PHP CURL is:

https://maps.googleapis/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true&key=XXXXXXXXXXXX

我得到的结果:

Array ([error_message] => This IP, site or mobile application is not authorized to use this API key. [results] => Array ( ) [status] => REQUEST_DENIED)

有什么我需要配置的吗.地理编码 API 也打开了.

Is there anything that I need to configure.The geocoding API is also switched on.

推荐答案

我遇到了同样的问题,我发现了这个问题.

在 url 上,它最终需要服务器密钥,而不是应用程序的 api 密钥.

On the url, it requires the server key in the end and not the api key for the app.

所以基本上,您只需在 URL 末尾添加服务器密钥,如下所示:

So Basically, you just add the server key in the end of the URL like this:

https://maps.googleapis/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&sensor=true&key=SERVERKEY

现在,要获取服务器密钥,只需按照以下步骤操作:

Now, to obtain the server key, just follow these steps:

1) 转到开发者控制台 https://code.google/apis/控制台/

2) 在凭据中,在公共 API 访问下,创建新密钥

2) In the Credentials, under Public API Access, Create New key

3) 从选项中选择服务器密钥.

3) Select the server key from the option.

4) 在字段中输入您的 IP 地址,如果您有更多 IP 地址,您可以在每一行添加.注意:仅输入 IP 地址当您想将其用于测试目的时.否则将 IP 地址部分留空.

4) Enter your IP Address on the field and if you have more ip addresses, you can just add on every single line.NOTE: Enter the IP Address only when you want to use it for your testing purpose. Else leave the IP Address section blank.

5) 完成后,单击创建,您的新服务器密钥将生成,然后您可以将该服务器密钥添加到您的 URL.

5) Once you are done, click create and your new Server Key will be generated and you can then add that server key to your URL.

最后一件事是,您可以像这样将 sensor=true 添加到最后,而不是将其放在 URL 中间:

Last thing is that, instead of putting the sensor=true in the middle of the URL, you can add it in the end like this:

https://maps.googleapis/maps/api/place/nearbysearch/json?location=yourlatitude,yourlongitude&radius=5000&key=SERVERKEY&sensor=true

这肯定会解决问题,只需记住使用 Places API 的服务器密钥.

This will definitely solve the issue and just remember to use the server key for Places API.

编辑

我相信网址在过去几年中发生了变化.您现在可以从这里访问开发者控制台 - https://console.developers.google/apis/仪表板

I believe the web URL has changed in the past years. You can access developers console from here now - https://console.developers.google/apis/dashboard

导航到开发者控制台 - https://console.developers.google/ 或使用直接导航到 API 仪表板的详细信息链接.在开发者控制台下,从左侧导航面板中找到标签选择项目从左侧导航面板中选择凭据您可以根据需要从顶部导航栏创建凭据类型. Navigate to developers console - https://console.developers.google/ or use the link from details to navigate directly to API dashboard. Under developer console, find Label from the left navigation panel Select project Choose Credentials from the left Navigation panel You could create credentials type from the Top nav bar as required.

希望这个回答对您和其他观众有所帮助.祝你好运.. :)

Hope this answer will help you and other viewers. Good Luck .. :)

这篇关于此 IP、站点或移动应用程序无权使用此 API 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-28 00:42:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/712578.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密钥   应用程序   站点   IP   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!