1
votes

I have a Google Shortener API credential setup on Developers Console. I have a Public API access created for a key, with the allowed IP of 199.180.250.40.

But when I call the API, I get this Google error:

There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.

I made sure my server is 199.180.250.40, and the script is running off that server. I've triple checked, including visiting whatismyip using lynx.

I'm using this code: https://github.com/sebi/googl-php

With this code:

        $googl = new Googl("my-key");
        $short = $googl->shorten($url);
        unset($googl);

Why is it rejecting even though that is my servers exact IP?

I don't send userIp but Google says:

If the userIp parameter is missing, your machine's IP address will be used instead.

Are there any access logs available on Google's side I can review?

1
Can you double check what IP address the outside world can see you as. Go to whatsmyip.com and see what it says. Other than that, make sure you aren't using any proxies or VPN'sMarshallOfSound
Yeah It used lynx to that website to verify the server IP address. It is correct. No proxies on the server.Zeno
IPv4 vs IPv6 can often cause such troubles … if your server connects to Google via IPv6, then the IPv4 address you specified obviously won’t match … (And if your checks with whatsmyip and lynx only used an IPv4 connection, then they “prove” the wrong thing.)CBroe
Is there any sort of detailed request log you view on the google dev console? Perhaps it will reveal an inconsistency.Jordan
@Jordan I'm hoping so! I've been unable to find any access logs though, yet.Zeno

1 Answers

0
votes

As mentioned in the comments, the server was using IPv6 and thus didn't match the IPv4 I entered. I entered my IPv6, and it worked.

There was also a "requests per second limit" set to 5 or so. This was a bit low, so I had move it up to 30.