1

我試圖實現從我的筆記本電腦連接到谷歌API使用方法OAuth 2.0 for Server to Server Applications。我正在使用PHP。錯誤的JSON爲谷歌API PHP客戶端與服務帳戶

我聲明瞭該帳戶並下載了關聯的JSON文件。

我也讀過this changelog。原始文件似乎過時了,因爲它使用P12策略。

我編寫:

set_include_path(get_include_path() . PATH_SEPARATOR . '/home/samuel/workspace/DABphp/lib/Google/'); 
require_once 'autoload.php'; 
[...] 
$client = new Google_Client(); 
$client->setAuthConfig('private/DABmap-2.json'); 
$client->useDefaultApplicationCredentials(); 
$client->addScope('https://www.googleapis.com/auth/fusiontables'); 
if ($client->getAuth()->isAccessTokenExpired()) { 
    $client->getAuth()->refreshTokenWithAssertion(); 
} 

我得到這個錯誤: '無效的客戶端機密JSON文件'

未捕獲的異常 'Google_Exception' 有消息在/home/samuel/workspace/DABphp/lib/Google/Client.php:171堆棧跟蹤:#0 /home/samuel/workspace/DABphp/ajouter-dab.php(80):Google_Client-> setAuthConfig('private/DABmap -...')#1 {main}

我試着再次下載一個新的密鑰。我沒有碰到這個文件。這是一樣的。

回答

相關問題