In addition to the API key that is assigned to you, Google also verifies the source of the incoming request by looking at either the REFERRER
or the IP address. To run an example in curl, create a new Server Key
in Google APIs console. While creating it, you must provide the IP address of the server. In this case, it will be your local IP address. Once you have created a Server Key
and whitelisted your IP address, you should be able to use the new API key in curl.
My guess is you probably created your API key as a Browser Key
which does not require you to whitelist your IP address, but instead uses the REFERRER
HTTP header tag for validation. curl doesn't send this tag by default, so Google was failing to validate your request.