我在验证日历API和google驱动器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中的身份验证适用于谷歌驱动器。
已修复。。在此之前,我在没有谷歌驱动api作用域的情况下对谷歌服务进行了身份验证,显然身份验证不会覆盖。