Google API returning Access Not Configured
Asked Answered
L

5

17

I thought this would be straight forward, but for some reason I'm getting hammered on this one.

I'm using PHP + CURL to try and retrieve a list of Web Fonts. The code is simple:

        $url = "https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key=MY_SERVER_APPS_KEY";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $google_response = curl_exec($ch);
        curl_close($ch);            

The code is hitting Google, but $google_response always returns:

"error": {
    "code": 403,
    "errors": [
        {
            "domain": "usageLimits",
            "reason": "accessNotConfigured",
            "message": "Access Not Configured"
        }
    ],
    "message": "Access Not Configured"
}

I've set up a server access key and put both of my web server's API keys on it. (To verify my IP, I did a WGET on curlmyip.com) I've also enabled the "Web Fonts Developer API" from the Services tab.

Is there anything I could be overlooking?

Lockett answered 15/1, 2013 at 23:14 Comment(0)
L
21

I found the solution. Apparently I needed to register my server's IPv6 address, not the IPv4's. Worked without any code changes after adding them.

Lockett answered 17/1, 2013 at 6:32 Comment(7)
Hey Anthony. where should one do that configuration ?Mayhem
@KiranRuthR It's surprisingly hidden. Visit code.google.com/apis/console. First, make sure the service you want is enabled under "Services". Then go to "API Access" and specify your calling domains or IP addresses.Lockett
@Anthony: Even I am facing the same problem using my localhost. Should i add IPv6 of my localhost?Transmit
@Transmit I have no idea whether localhost will work. Most likely it'd be the IP address of your machine. Try going to whatismyv6.com and provide that, since that is where your traffic will be calling from.Lockett
Thank you... I already had localhost in but had not turned on access for Calendar.Mirilla
It works for me. I had to define the IPv6 address, because "any IP allowed" didn't worked for me. Tak care!Stantonstanway
I've converted my IPv4 into an IPv6 address, but Google says it's not a valid address... This is what I'm trying to enter: 2002:0:0:0:0:0:400d:c03cDeery
S
14

In my case the needed API was not enabled.

To enable:

  1. Go to https://console.developers.google.com
  2. Click the menu icon in the top left
  3. Click API Manager from the menu
  4. Search for your API in the search bar (e.g. YouTube Data API v3) and click on it
  5. Once on the subpage for that API, click Enable in the top left
Stonge answered 20/1, 2016 at 21:23 Comment(0)
R
4

remove all "allowed Ips", then Any IP allowed

Ronnaronnholm answered 30/4, 2014 at 5:53 Comment(2)
Brayon, Explain how you configured allowed Ips?Bahner
Thank you. Yes, removing all allowed IPs worked for my "Public API access" server key. It didn't work immediately (testing with cli curl) , so I regenerated the key. The new one worked immediately, but a few minutes later the original worked as well.Corsica
F
0

I attempted the solutions listed above in order and wasn't able to get a result. The YouTube, Dialogflow and Google+ API integrations had been inactive for a few months when this happened.

Eventually the only solution was:

  • Create a new project
  • Create a new key
  • Copy the IPv4 and IPv6 Addresses under the Application Restrictions
  • Update the API restrictions based on the needs of you application
Fowler answered 29/3, 2020 at 4:23 Comment(0)
M
0

For anyone receiving similar errors but not knowing what the actual problem is, make sure to set

curl_setopt($ch, CURLOPT_FAILONERROR, false);

in order to receive a valid CURL response, which includes the error description from Google.

Millar answered 25/10, 2022 at 15:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.