Php (403)您的API密钥上配置了每IP或每引用限制,请求与这些限制不匹配

Php (403)您的API密钥上配置了每IP或每引用限制,请求与这些限制不匹配,php,google-api,google-drive-api,Php,Google Api,Google Drive Api,我正在尝试将在线服务器上的PHP应用程序连接到Google Drive API,我已为API密钥提供了正确的凭据,如下所示: 这是我的密码: Class googleDriveAPIController Extends baseController { /** * Retrieve a list of File resources. * * @param Google_Service_Drive $service

我正在尝试将在线服务器上的PHP应用程序连接到Google Drive API,我已为API密钥提供了正确的凭据,如下所示:

这是我的密码:

    Class googleDriveAPIController Extends baseController {


        /**
         * Retrieve a list of File resources.
         *
         * @param Google_Service_Drive $service Drive API service instance.
         * @return Array List of Google_Service_Drive_DriveFile resources.
         */
        function retrieveAllFiles($service) {
          $result = array();
          $pageToken = NULL;

          do {
            try {
              $parameters = array();
              if ($pageToken) {
                $parameters['pageToken'] = $pageToken;
              }
              $files = $service->files->listFiles($parameters);

              $result = array_merge($result, $files->getItems());
              $pageToken = $files->getNextPageToken();
            } catch (Exception $e) {
              print "An error occurred: " . $e->getMessage();
              $pageToken = NULL;
            }
          } while ($pageToken);
          return $result;
        }




        public function index() {

        set_include_path('google-api-php-client/src');
        require_once(get_include_path() . '/Google/autoload.php');
        require_once(get_include_path() . '/Google/Client.php');
        require_once(get_include_path() . '/Google/Service.php');
        require_once(get_include_path() . '/Google/Http/MediaFileUpload.php');
        require_once(get_include_path() . '/Google/Service/Drive.php');

        $client = new Google_Client();
        $client->setApplicationName("My Application");
        $client->setDeveloperKey("AIzaSyAmWcZArf7NCk4d65HoKZzLENCJ6cx9fNg");
        $service = new Google_Service_Drive($client);           
        $this->retrieveAllFiles($service);      

        }
}
我得到以下错误:

发生错误:调用GET时出错 : (403)在您的服务器上配置了每IP或每引用限制 API密钥和请求与这些限制不匹配。请使用 如果需要,Google开发者控制台将更新API密钥配置 应允许来自此IP或referer的请求

我已经授权访问此应用程序,所以不确定这里发生了什么,有人知道我做错了什么吗


非常感谢

您的问题是需要修复限制。您必须从错误的位置运行它

*shabazejaz.co.uk/*
可能是一个更好的值。您需要对其进行测试

旁注:

浏览器API密钥用于访问公共数据

列出用户的文件


为了能够运行file.list,必须使用Oauth2或服务帐户对您进行身份验证。浏览器API密钥不起作用。

您是从运行脚本的吗?是的,我甚至输入了shabazejaz.co.uk/*以便它可以用于该域下的所有内容,但仍然会收到相同的错误