简体   繁体   中英

Directions API Request Denied Android Client

I am trying to make a request to directions api from android. 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 . How do I obtain a server key? Isn't it the same as the api key I receive on registering directions or maps 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"

  • SO you need Intermediate server and then you need to restrict using server IP..

  • So give restriction as none.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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