Google API返回未配置的访问权限 [英] Google API returning Access Not Configured
问题描述
我认为这将是直接的,但出于某种原因,我正在为这一个敲响。
我使用PHP + CURL来尝试和检索Web字体列表。代码很简单:
$ url =https://www.googleapis.com/webfonts/v1/webfonts?sort =知名度和放大器;关键= 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);
代码击中Google,但$ google_response始终返回:
error:{
code:403,
errors:[
{
domain :usageLimits,
reason:accessNotConfigured,
message:Access Not Configured
}
],
message: Access Not Configured
}
我设置了服务器访问密钥,我的网络服务器的API密钥都在它上面。 (为了验证我的IP,我在curlmyip.com上做了一个WGET)我也从Services选项卡启用了Web Fonts Developer API。
我可以忽略?
我找到了解决方案。显然我需要注册我的服务器的IPv6地址,而不是IPv4的。在添加它们之后无需更改任何代码。
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?
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.
这篇关于Google API返回未配置的访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!