简体   繁体   English

路线API请求被拒绝的Android客户端

[英]Directions API Request Denied Android Client

I am trying to make a request to directions api from android. 我正在尝试从Android向路线API发出请求。 I have constructed my request url like below: 我已经构造了我的请求网址,如下所示:

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

but on testing the endpoint, I get this error: 但是在测试端点时,出现此错误:

{
   "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"
}

I have looked at other questions similar to this and there's a mention of server key and browser key . 我查看了与此类似的其他问题,其中提到了server key and browser key How do I obtain a server key? 如何获取服务器密钥? Isn't it the same as the api key I receive on registering directions or maps api ? 它与我在注册directions or maps api收到的api密钥不同吗?

Thanks for any help. 谢谢你的帮助。

  • Make sure Application restriction is "none" in Developer console.. 确保开发者控制台中的“应用程序限制”为“无”
  • Direction API need IP restriction, by using Android if you give Android restriction it will respond as "request_denied" Direction API需要IP限制,如果您指定Android限制,则使用Android,它将响应为“ request_denied”

  • SO you need Intermediate server and then you need to restrict using server IP.. 因此,您需要中间服务器,然后需要限制使用服务器IP。

  • So give restriction as none. 因此,不要限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM