Google API returning Access Not Configured

爷,独闯天下 提交于 2019-12-03 23:39:30

问题


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?


回答1:


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.




回答2:


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



回答3:


remove all "allowed Ips", then Any IP allowed



来源:https://stackoverflow.com/questions/14348689/google-api-returning-access-not-configured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!