'How to use API keys to Authenticate Requests From an API
I'm Trying to get the latitude and longitude of an address using the Geocoding API. That's my code:
JSONObject jsonObject = new JSONObject(response.body().toString());
Toast.makeText(TrackingOrder.this, jsonObject + " ", Toast.LENGTH_SHORT).show();
String lat = ((JSONArray) jsonObject.get("results"))
.getJSONObject(0)
.getJSONObject("geometry")
.getJSONObject("location")
.get("lat").toString();
String lng = ((JSONArray) jsonObject.get("results"))
.getJSONObject(0)
.getJSONObject("geometry")
.getJSONObject("location")
.get("lng").toString();
The Problem is I'm receiving "Access Denied" response
"error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account",
"results" : [],
"status" : "REQUEST_DENIED"
}
I Generate an API Key, restrict it, link it with my android app (Name,SHA)and enable Geocoding API I try to call this request on the Browser the same problem(the same Output):
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
