此 IP、站点或移动应用程序无权使用此 API 密钥 - Android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23938711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
This IP, site or mobile application is not authorized to use this API key - Android
提问by Mitja Rogl
I have a problem with connection with Google maps API V2 and Android. I' ve enabled services:
我在连接 Google 地图 API V2 和 Android 时遇到问题。我已启用服务:
- Google Maps Android API v2
- Places API
- 谷歌地图 Android API v2
- 地点 API
Also I've added sha1 fingerprint.
我还添加了 sha1 指纹。
But I still get this message: This IP, site or mobile application is not authorized to use this API key
但我仍然收到此消息:此 IP、站点或移动应用程序未被授权使用此 API 密钥
I'm calling service from Android. Do you know where might be the problem, cause I don't know where to search.
我正在从 Android 调用服务。你知道问题出在哪里吗,因为我不知道去哪里搜索。
回答by Illegal Argument
You must be creating a browser key instead of an android key. I faced similar problem when I accidentely created an android key for Google Cloud Messaging instead of a server key. Please check which key is required for your purpose. For google maps v2 you need android key and for google places api you need a server key(searched google but not so sure on this one never used it). So basically you need two keys.
您必须创建浏览器密钥而不是 android 密钥。当我不小心为 Google Cloud Messaging 创建了一个 android 密钥而不是服务器密钥时,我遇到了类似的问题。请检查您的目的需要哪个密钥。对于谷歌地图 v2,你需要 android 密钥,而对于谷歌地点 api,你需要一个服务器密钥(在谷歌上搜索过,但不确定这个从未使用过)。所以基本上你需要两把钥匙。
Update: You need server key for places api.
更新:您需要场所 api 的服务器密钥。
回答by Ruchir
Refer this tutorial.
请参阅本教程。
http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/
http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/
Step 1- Go to code.google.com/apis/console/?noredirect
第 1 步- 转到code.google.com/apis/console/?noredirect
Step 2- Create a new project
第 2 步- 创建一个新项目
Step 3- Go to services and choose Places API, turn it on. This will ask your organization name and url.Fill them and click Ok.
第 3 步- 转到服务并选择 Places API,将其打开。这将询问您的组织名称和 URL。填写它们并单击确定。
Step 4- Now go to API Access and there will be your API Key. You don't have to click on Create new key. This will be your browser apps key which you can use in your Android Apps.
第 4 步- 现在转到 API Access,就会有您的 API 密钥。您不必单击“创建新密钥”。这将是您可以在 Android 应用程序中使用的浏览器应用程序密钥。
This solution worked for me perfectly.
这个解决方案对我来说非常有效。
回答by Michael James
If generating an Android App, the "Server" IP address could be any IP of any phone on any network. What do I write in the "Accept requests from these server IP addresses" box in order to have any IP address accepted?
如果生成 Android 应用程序,“服务器”IP 地址可以是任何网络上任何电话的任何 IP。我在“接受来自这些服务器 IP 地址的请求”框中写什么才能接受任何 IP 地址?
Edit - Apologies. Apparently just leave it blank...
编辑 - 道歉。显然只是把它留空......
回答by Hari Enaganti
I just had this issue the other day, it is not actually an issue with this library.
前几天我刚遇到这个问题,这实际上不是这个库的问题。
First, make sure you're using a server API key, not an Android/iOS key (if you're doing mobile development). See this stackoverflow post: Google Places API request denied for Android autocomplete, even with the right api key. The TL;DR version of that link is that Google Places API doesn't support the Android/iOS key option, only the server option.
首先,确保您使用的是服务器 API 密钥,而不是 Android/iOS 密钥(如果您正在进行移动开发)。请参阅此 stackoverflow 帖子:Google Places API request denied for Android autocomplete, even with right api key。该链接的 TL;DR 版本是 Google Places API 不支持 Android/iOS 密钥选项,仅支持服务器选项。
Second, and this goes without saying, make sure you're passing the key to the GooglePlaces instance.
其次,不用说,确保您将密钥传递给 GooglePlaces 实例。
Lastly, if you're restricting use of the API key by IP make sure your request is coming from an allowed address.
最后,如果您通过 IP 限制 API 密钥的使用,请确保您的请求来自允许的地址。
回答by Sam003
You don't need to create a key for using Google place API, instead just use "Key for browser apps (with referers)". But if you want to use Google Map API, you need to generate a Android Key, and you could find instruction here :https://developers.google.com/maps/documentation/android/start.
您无需为使用 Google Place API 创建密钥,而只需使用“用于浏览器应用程序的密钥(带引用)”。但是如果你想使用谷歌地图API,你需要生成一个Android Key,你可以在这里找到说明:https: //developers.google.com/maps/documentation/android/start。
Good luck.
祝你好运。
回答by Rezpa Aditya
I got this problem too. but I SOLVED this issue only using something tricky. Go to your google console and create new key which is browser key, then let the column empty and save. you can use the key that has been created in you mobile apps now. GOOD LUCK! *Unfortunately I can't post an image to this answer
我也遇到了这个问题。但我只使用一些棘手的东西解决了这个问题。转到您的 google 控制台并创建新密钥,即浏览器密钥,然后将该列清空并保存。您现在可以使用在您的移动应用程序中创建的密钥。祝你好运!*不幸的是,我无法在此答案中发布图片
回答by Hari Enaganti
Change your API key, you may use Android key in the URL. For to specify Key in the URL you need to get WEBSERVICE key.
更改您的 API 密钥,您可以在 URL 中使用 Android 密钥。要在 URL 中指定密钥,您需要获取 WEBSERVICE 密钥。