Anthony
Anthony

Reputation: 5433

Google API returning Access Not Configured

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?

Upvotes: 17

Views: 28936

Answers (5)

mavrosxristoforos
mavrosxristoforos

Reputation: 3643

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.

Upvotes: 0

Eric Kigathi
Eric Kigathi

Reputation: 2031

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

Upvotes: 0

Nelu
Nelu

Reputation: 18790

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

Upvotes: 14

Baryon Lee
Baryon Lee

Reputation: 1177

remove all "allowed Ips", then Any IP allowed

Upvotes: 4

Anthony
Anthony

Reputation: 5433

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.

Upvotes: 21

Related Questions