0

I created API Keys to enable Geocoding API, Maps JavaScript API and Places API with Restrict IP with Cloud NAT IP. My API Keys access from Kubernetes on GCP (Google Kubernetes Engine/GKE), when im test curl get response request denied because response from from IPV6 Address.

curl --location --request GET 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Wonogiri&types=&key=MY-API-KEY'
{
   "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address IPV6_ADDRESS, with empty referer",
   "predictions" : [],
   "status" : "REQUEST_DENIED"
}

But im curl to ifconfig.me the response is IP Cloud NAT (34.87.xxx.xx). Im very confused.

restrictions from ip address enable 3 google api

1 Answers1

0

Based on the response from the API, I suspect you have to set an http referrer header.

curl --referer Referer_URL \ 
   --location \ 
   --request GET \ 
   'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Wonogiri&types=&key=MY-API-KEY'

I would check the restrictions because you might have enabled "website" restrictions and so the referrer is required.

If you have IP restrictions, make sure to add the IP to the list and to save the api key. It should work instantly.

The IP addresses should be the external IP addresses of the nodes in the cluster.

ekawas
  • 101
  • 4