0

我正在使用最新版本的 Google Client PHP 来从 YouTube 获取数据。

我从 Google 开发者控制台(新旧版本)创建了一个服务器 API 密钥,启用了 Youtube API 并将我的个人 IP 列入白名单以允许访问 API。这工作没有任何问题!

奇怪的是,当我在我的(在线)服务器上运行代码时,我不断收到此错误:

                [domain] => usageLimits
                [reason] => accessNotConfigured
                [message] => Access Not Configured. The API is not enabled for your project, or 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 configuration.
                [extendedHelp] => https://console.developers.google.com

我试图在不同的在线服务器上运行代码,同时将它的 IP 列入白名单,但它一直给我这个错误。当我尝试从我自己的计算机使用不同的 IP(家庭、工作、邻居)运行代码时,它也会给我同样的错误,但在我将当前 IP 列入白名单后,错误就会消失。所以白名单似乎解决了这个问题,但只在我的本地机器上而不是在任何在线服务器上。

我已经尝试生成新的 API 密钥,但没有任何运气。我还尝试附加 userIp 参数,如控制台文档中提供的那样。仍然没有运气。

我没主意了。有人知道可能出了什么问题吗?

4

1 回答 1

0

我已经通过清除 Google Developer 控制台中的允许 IP 字段解决了我自己的问题。

通过将此字段保留为空,它允许任何 IP。偶然发现了这个。

我仍然不知道这是怎么回事,即使我 100% 确定我使用了正确的 IP 地址,但它给了我这个错误。

于 2015-01-27T11:05:39.803 回答