谷歌地点API密钥未授权。

3

我正在使用Android应用程序中的Google Places,但是遇到了这个错误

{
   "error_message" : "This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
   "html_attributions" : [],
   "results" : [],
   "status" : "REQUEST_DENIED"
}

我已经尝试使用Android key、浏览器key和服务器key,但是这些都无法工作,请帮我解决问题。我不知道这个key出了什么问题……! 请帮帮我。 我正在使用的URL是:
https://maps.googleapis.com/maps/api/place/search/json?radius=50&sensor=true&key=<my key>&location=22,75

可能是重复问题:https://dev59.com/iozda4cB1Zd3GeqPkUhx - Daniel Nugent
@DanielNugent 仍然遇到了相同的错误。 - AnonymousDev
您是否在开发者控制台中启用了“Google Places API Web Service”? - Daniel Nugent
你的链接现在对我有效,所以我猜你的问题已经解决了。将来不要发布你的API密钥。 - Daniel Nugent
是的,现在它也对我起作用了,谢谢@DanielNugent,你帮了我很多,谢谢啊,我欠你一个人情。 - AnonymousDev
是的,我会编辑这篇帖子并删除我的密钥。 - AnonymousDev
5个回答

3
为了确保启用有效的 API,您需要为每个有效的密钥启用相应的 API。请注意:
- 在浏览器 API 服务器上启用 Place API,请使用浏览器密钥。 - 在 Android 应用中使用 Place API,请使用 Android 密钥。

2

1
请注意,此问题中的API需要服务器密钥,无需指定sha1值或包名称。 - Daniel Nugent
@user3508256 是的,我也用过浏览器密钥,并且它运行良好!尽管文档说只能使用服务器密钥。 - Daniel Nugent

2
请确保您已启用“Google Places API Web Service”(在您的 Google Api 控制台上,https://console.developers.google.com)。您必须使用服务器密钥(而不是 Android 密钥)。 Enable api set credentials

0

"status" : "REQUEST_DENIED" 表示启用 Google API 权限时出现问题。请确保您已启用以下 API:

  • Google Maps Android API
  • Google Maps Geocoding API
  • Google Maps Geolocation API
  • Google Places API for Android
  • Google Places API Web Service

0

"status" : "REQUEST_DENIED" - 表示启用 Google API 权限时出现问题。 请确保您已启用以下 API:

Google Maps Android API
Google Maps Geocoding API
Google Maps Geolocation API
Google Places API for Android
Google Places API Web Service

我也遇到了同样的问题,但在浏览开发者网站后,我发现还需要启用 Places API for Web Service,这对我很有帮助。

希望这可能会有所帮助!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接