2016-04-19 45 views
0

我无法验证日历API和谷歌驱动器API。我有日历API工作,我想添加谷歌驱动器附件功能,但不能让它工作。它给我这个错误 时出现错误:错误调用get https://www.googleapis.com/drive/v2/files:(403)没有足够的权限403权限拒绝谷歌驱动器API PHP

这里是我的代码:

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中的身份验证适用于谷歌驱动器。

回答

0

固定..我认证谷歌服务之前,没有谷歌驱动器API范围,显然认证不覆盖。