Hi, I solved by applying a slight modification to the class Google_REST.php , it would be better not to fix it , but I have not found other solutions, however, it may be helpful , in my case the token encoded in JSON format was transmitted according to this here : Protection : 1; mode = block Server : GSE Alternate- Protocol: 443: quic Transfer-Encoding: chunked and after {key : value , key: value , etc. } .
For some reason unknown to me , were added in most of the information that was not necessary that , at the time of decoding the JSON format , obviously returned NULL , probably due to an error in JSON format.
/**
* Decode an HTTP Response.
* @static
* @throws Google_ServiceException
* @param Google_HttpRequest $response The http response to be decoded.
* @return mixed|null
*/
public static function decodeHttpResponse($response) {
$code = $response->getResponseHttpCode();
$body = $response->getResponseBody();
$decoded = null;
if ((intVal($code)) >= 300) {
//*********************BUG RISOLTO********************
echo "<br>TOKEN PRIMA: ".$body."<br>";
$pattern = '/{.*}/';
preg_match($pattern, $body, $body);
echo "<br>TOKEN DOPO: ";
print_r($body[0]);
//****************************************************
$decoded = json_decode($body[0], true);
//$decoded = json_decode($body, true);
$err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
if ($decoded != null && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
// if we're getting a json encoded error definition, use that instead of the raw response
// body for improved readability
$err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
} else {
$err .= ": ($code) $body";
}
throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']);
}
// Only attempt to decode the response, if the response code wasn't (204) 'no content'
if ($code != '204') {
//*********************BUG RISOLTO********************
echo "<br>TOKEN PRIMA: ".$body."<br>";
$pattern = '/{.*}/';
preg_match($pattern, $body, $body);
echo "<br>TOKEN DOPO: ";
print_r($body[0]);
//****************************************************
$decoded = json_decode($body[0], true);
//$decoded = json_decode($body, true);
if ($decoded === null || $decoded === "") {
throw new Google_ServiceException("Invalid json in service response: $body");
}
}
return $decoded;
}
I hope to be helpful in some way. Let me know if you have solved another way.
Bye.
PS : Another tip is to try to download the latest version of the Google API , maybe the problem resolves itself .