refreshTokenWithAssertion Failing reauthentication
I am running a script to patch 2000 business using Google My Business At record 900 i get "code": 401, "message": "Request had invalid authentication credentials.",
Before each curl call I am checking the token
if ($client->isAccessTokenExpired()) { $oauth2Token = $client->refreshTokenWithAssertion()['access_token']; }
Are there any timeout issues here? Is this the correct implementation for "google/apiclient": "2.0.0-RC7"
What you are doing looks correct. It does seem like refreshTokenWithAssertion is not successfully fetching the token.
I would debug what is being returned first, and see if that sheds any light on the issue. If a JSON error is the response from the HTTP server, then that error will be returned from refreshTokenWithAssertion:
if ($client->isAccessTokenExpired()) {
$result = $client->refreshTokenWithAssertion();
if (!isset($result['access_token'])) {
throw new \Exception('unexpected response: ' . json_encode($result));
}
$oauth2Token = $result['access_token'];
}
If that doesn't work, you should be able to use a web proxy like Charles to debug the HTTP request going across the wire:
$client = new Google_Client;
$http = new GuzzleHttp\Client([
'proxy' => 'localhost:8888', // this is where charles is running
'verify' => false,
]);
$client->setHttpClient($http);
This issue has been closed due a lack of response. Please reopen with more information if the problem is still occurring.