我尝试使用google-api-php-client客户端使用服务帐户连接到Google云端硬盘。如支持人员所述,所有帐户设置均正确设置。但是我有错误{“ error”:“ invalid_grant”}
include_once __DIR__ . '/vendor/autoload.php';
include_once __DIR__ . '/vendor/google/apiclient/examples/templates/base.php';
$client = new Google_Client();
if ($credentials_file = checkServiceAccountCredentialsFile()) {
$client->setAuthConfig($credentials_file);
} elseif (getenv('GOOGLE_APPLICATION_CREDENTIALS')) {
$client->useApplicationDefaultCredentials();
} else {
echo missingServiceAccountDetailsWarning();
return;
}
$client->setApplicationName('name-server-google-suite-drive');
$client->addScope(Google_Service_Drive::DRIVE);
$client->setSubject('account_email');
我正在尝试创建Google客户端,但没有授权。在客户端设置中还应该指定什么才能授权工作?