My goal is to trigger a google cloud function through my php code. For that I need an identity token as the Bearer, but my server does not have gcloud installed on it. I have a working service-account and I created an object through the Google_Client ("google/apiclient": "2.10.1"):
$this->setAuthConfig($serviceJson);
$scope = [Google_Service_Compute::CLOUD_PLATFORM, 'openid', 'email'];
$this->addScope($scope);
if ($this->isAccessTokenExpired()) {
$this->fetchAccessTokenWithAssertion();
}
$this->getAccessToken()
Using this client I can fetch only the access_token (which is unauthorized to trigger a cloud function) but the id_token is always empty.
How can I get the id_token? Is there a php library that can help or do I need to do a separate POST request(s) to get the id_token?
The only way I found is like this: