谷歌驱动器api PHP拒绝403权限

时间:2016-04-19 22:03:05

标签: google-api google-api-php-client

我无法验证日历API和google drive API。我有日历API工作,我想添加谷歌驱动器附件功能,但无法使其工作。它给了我这个错误 发生错误:调用GET https://www.googleapis.com/drive/v2/files时出错:(403)权限不足

这是我的代码:

define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->addScope("https://www.googleapis.com/auth/drive");
$client->addScope("https://www.googleapis.com/auth/calendar");

$googleService = new Google_Service_Calendar($client);
$drive_service = new Google_Service_Drive($client);*/
define('SCOPES', implode(' ', array(
  Google_Service_Drive::DRIVE_METADATA_READONLY)
));

// Setup the Google Calendar class
$googleClient = new Google_Client();
$googleClient->setApplicationName('test');
$googleClient->setScopes(SCOPES);
$googleClient->addScope("https://www.googleapis.com/auth/drive");
$googleClient->addScope("https://www.googleapis.com/auth/Calendar");
$googleClient->setAuthConfigFile(CLIENT_SECRET_PATH);
$googleService = new Google_Service_Calendar($googleClient);
$driveService = new Google_Service_Drive($googleClient);

我不知道为什么日历有效并且谷歌驱动器没有,我很确定CLIENT_SECRET_PATH中的身份验证适用于谷歌驱动器。

1 个答案:

答案 0 :(得分:0)

已修复..我在没有谷歌驱动器api范围之前验证了谷歌服务,显然认证不会覆盖。