I cannot get this to work, have been looking at several other related questions and answers and I think the problem is somewhere in the fact that I'm using a service account for this. The situation is:
- I have a Google Service Account and a Google Calendar ID (access with service key)
- I can create a new event in the calendar without any problem.
- When I also try to get a Google Meet link, I get an error: "Invalid conference type value"
This my code:
$client = new Google_Client();
$client->setAuthConfig(xxx);
$client->setScopes("https://www.googleapis.com/auth/calendar");
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
"description" => "Test",
"start" => array(
"dateTime" => "2021-09-01T09:00",
"timeZone" => "Europe/Brussels",
),
"end" => array(
"dateTime" => "2021-09-01T10:00",
"timeZone" => "Europe/Brussels",
)
));
// add google meet link
$solution_key = new Google_Service_Calendar_ConferenceSolutionKey();
$solution_key->setType("hangoutsMeet");
$confrequest = new Google_Service_Calendar_CreateConferenceRequest();
$confrequest->setRequestId("X".time());
$confrequest->setConferenceSolutionKey($solution_key);
$confdata = new Google_Service_Calendar_ConferenceData();
$confdata->setCreateRequest($confrequest);
$event->setConferenceData($confdata);
$event = $service->events->insert($google_calendar_id, $event, array('conferenceDataVersion' => 1));
Without the parameter "array('conferenceDataVersion' => 1)" the event is being created. I'm almost sure it has something to do with access rights, but I don't know where to look anymore...