我正在尝试使用离线代码验证我的服务器端客户端:
$client = new Google_Client();
$client->setApplicationName('API');
$client->setClientId('...');
$client->setClientSecret('...');
$client->setRedirectUri('http://');
$client->setDeveloperKey('...');
$client->setAccessType("offline");
$client->setScopes('https://www.googleapis.com/auth/webmasters.readonly');
$client->setApprovalPrompt('force');
$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), ));
$client->setHttpClient($guzzleClient);
$client->authenticate($offline_code));
输出:
<b>Fatal error</b>: Uncaught exception
'GuzzleHttp\Exception\ClientException' with message 'Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `400 Bad Request` response:
invalid_grant
Bad Request
我正在使用的凭据可以正常访问和刷新令牌,但这需要用户交互。我还仔细检查了向同一个应用程序发出了脱机令牌。我还应该检查什么?