我正在尝试从 android 向 directions api 发出请求。我已经构建了我的请求 url,如下所示:
https://maps.googleapis.com/maps/api/directions/json?mode=driving&transit_routing_preference=less_driving&origin=12.84938,77.6554783&destination=151,+9th+Main+Road,+HSR+Layout+Sector+6,+Bengaluru,+Karnataka+560102&key=MYAPI_KEY
但是在测试端点时,我得到了这个错误:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 223.227.127.66, with empty referer",
"routes" : [],
"status" : "REQUEST_DENIED"
}
我看过其他与此类似的问题,其中提到了服务器 key 和浏览器 key
。如何获取服务器 key ?它与我在注册 directions 或 maps api
时收到的 api key 不一样吗?
感谢您的帮助。
最佳答案
- 确保开发人员中的应用程序限制为“无” 控制台..
Direction API 需要 IP 限制,如果您提供,则使用 Android Android 限制它将响应为 "request_denied"
所以你需要中间服务器然后你需要限制使用 服务器IP..
- 所以限制为无。
关于android - Directions API 请求被拒绝 Android 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50769742/