I am trying to create a Google project service account using the PHP client library as demonstrated https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts/create but I am getting this error
Undefined property: Google\Service\Iam::$projects_serviceAccounts
.
I am not sure but it seems V2 is being loaded but I need to use V1.
Here is my method in my class
public function createServiceAccount()
{
$requestBody = new Google_Service_Iam_CreateServiceAccountRequest();
// Required: Set the account ID for the service account
$requestBody->setAccountId($this->googleProject->project_id);
// Optional: Set additional properties for the service account
$serviceAccount = new Google_Service_Iam_ServiceAccount();
$serviceAccount->setDisplayName($this->googleProject->project_display_name);
$serviceAccount->setDescription("Service account for {$this->googleProject->project_display_name}");
// Assign the service account details to the request body
$requestBody->setServiceAccount($serviceAccount);
$name = 'projects/' . $this->googleProject->project_id;
return $this->service->projects_serviceAccounts->create($name, $requestBody);
}
I am PHPStorm IDE that is showing me this warning
Property 'projects_serviceAccounts' not found in \Google_Service_Iam
Kindly help me figure out where I am going wrong.
I am creating a Laravel APP that needs to automate Google project creation as well as service accounts for these projects.
Check if this line is included on your php:
Since projects_serviceAccounts is included on the following namespace based on the google-api-php-client-services repository: