5
votes

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.

1
Check your request again something is wrong its not picking up your key. Check for spaces in your request parms you could also try putting key first but it shouldnt matter i suspect something needs to be encoded in your addressDaImTo
Please note that this would require further assistance from the Google Maps Platform support team, kindly file a support case via console.cloud.google.com/google/maps-apis/support in order to open personalized communication channel.Jean Gladys Raymundo
Make sure you are correctly encoding your URL and/or try generating a new key.MrUpsidown

1 Answers

4
votes

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