Google API PHP 使用服务帐户的客户的错误 JSON

Wrong JSON for Google API PHP client with service account

我正在尝试使用 OAuth 2.0 for Server to Server Applications 的方法实现从笔记本电脑到 Google 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();
}

我收到这个错误:

Uncaught exception 'Google_Exception' with message 'Invalid client secret JSON file.' in /home/samuel/workspace/DABphp/lib/Google/Client.php:171 Stack trace: #0 /home/samuel/workspace/DABphp/ajouter-dab.php(80): Google_Client->setAuthConfig('private/DABmap-...') #1 {main}

我尝试重新下载一个新密钥。我没有碰那个文件。也一样。

这似乎是一个已知错误 here