1
帶有服務帳戶憑證的谷歌驅動器API,要上傳特定用戶的文件j********@gmail.com。訪問谷歌驅動器api服務帳戶有時會失敗
我在Google開發人員API控制檯中創建了我的帳戶服務憑據。 我添加權限的用戶j****@gmail.com 本人授權我的應用程序的j****@gmail.com
但有時autetication失敗 本messagge
Google_Service_Exception
{
"error": "unauthorized_client",
"error_description": "Client is unauthorized to retrieve access tokens using this method."
}
這裏的我的身份驗證
if ($credentials_file = checkServiceAccountCredentialsFile()) {
// set the location manually
$client->setAuthConfig($credentials_file);
} elseif (getenv('GOOGLE_APPLICATION_CREDENTIALS')) {
// use the application default credentials
$client->useApplicationDefaultCredentials();
} else {
echo missingServiceAccountDetailsWarning();
return;
}
$client->setSubject('j******@gmail.com');
$client->setScopes(['https://www.googleapis.com/auth/drive']);
$service = new Google_Service_Drive($client);
$files = $service->files->listFiles();
您需要澄清何時「有時」,作爲識別問題的一種方式。 – Wolfie
有時候意思是說如果我刷新頁面,有三次或四次我有錯誤,這有點奇怪,非常感謝Gianmaria –
這裏是鏈接,只是有一個想法 http://advertising.fortale.it/basic/web/ –