I'm attempting to access Google's Geocoding API with the following:
curl https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=XXX
I get back the following:
{"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"}
They key I'm passing is associated to a project with both the Geocoding and Places APIs enabled, and the project has billing enabled as well.
Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.
Note: The Google Places API Web Service does not work with an Android or iOS restricted API key. So you have to create new key if or remove restricted access of existing key to work it properly. This is the correct answer for the Google reviews FYI.
I think the shell is interfering with some characters in your query. If you use bash or a similar shell, it works for me to surround the query address with single quotes or double quotes. For example:
curl 'https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=XXX'
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
...
For more convenience, you can store the key in a shell environment variable, and use double quotes for the shell to expand it in your query. Here is what I do:
export GOOGLE_MAPS_API_KEY=XXX
curl "https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=${GOOGLE_MAPS_API_KEY}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With