DrEdit示例访问未配置错误

时间:2013-09-19 19:35:58

标签: php google-drive-api google-drive-realtime-api

我正在尝试使用Google Drive API和Drive SDK编写我的第一个应用。我想从谷歌驱动器打开文件。这是我的代码:

if(isset($_GET['state'])){
    $json = $_GET['state'];
    $obj = json_decode($json);
    $idTab = $obj->{'ids'};
    $id = $idTab[0];
    $file = printFile($service, $id);
}
    function printFile($service, $fileId) {
    try {
        $file = $service->files->get($fileId);
        return $file;
    } catch (Exception $e) {
        print 'Error: '.$e->getMessage();
        return null;
      }
}

function downloadFile($file) {

    $downloadUrl = $file->getDownloadUrl();
      if ($downloadUrl) {
        $request = new Google_HttpRequest($downloadUrl, 'GET', null, null);
        $httpRequest = Google_Client::$io->authenticatedRequest($request);
        if ($httpRequest->getResponseHttpCode() == 200) {
            return $httpRequest->getResponseBody();
          } else {
          // An error occurred.
          return null;
        }
    } else {
    // The file doesn't have any content stored on Drive.
    return null;
  }
    }

我在Apis控制台中启用了Google Drive API和Drive SDK。我已经设置了我的客户端ID,电子邮件地址,Web应用程序的客户端密钥以及我的API密钥和允许的引用者(HTTP接受的请求)。我已在Google云端硬盘SDK中输入了所有必要的数据,例如客户ID,开放网址。我的附加范围是:[https://www.googleapis.com/auth/userinfo.profile],[https://www.googleapis.com/auth/drive.install],[https://www.googleapis。 com / auth / drive.file],[https://www.googleapis.com/auth/drive]。

我已经在谷歌商店安装了我的应用程序,我正在尝试通过我的应用程序从我的驱动器中打开文件。我有以下错误:

{
 "error": {
  "errors": [
  {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured"
   }
  ],
  "code": 403,
"message": "Access Not Configured"
 }
} 

我正在寻找并寻找解决方案而我找不到。什么都没有帮助。所以请有人帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

但是我已经开启了Drive SDK和Drive API服务,但仍然有错误。在帖子中您告诉我解决方案是打开Drive SDK和Drive API服务。在我看来,这不是解决方案。

相关问题