Using the Google APIs Client Library for PHP, I am trying to create a new calendar event and attach a hangoutsMeet
conference. When I attempt to do so, I receive an error stating Invalid conference type value
.
Using the same code, I am able to create a new event and attach an eventHangout
conference.
I understand why I am receiving the error: according to the API, my calendar only supports the eventHangout
conference type.
<<<< edit #1 on April 3 2020
Clarification following Andres Duarte's answer: this only appears as a limitation when I attempt to create an event via the API. When I manually create an event using the Google Calendar interface, I am able to add a Google Meet. In fact, that's the only conferencing option that's displayed in the dropdown.
>>>>
My question is, how can I update my calendar settings (with or without the API) such that I can use the API to create events with attached hangoutsMeet
conferences?
Here is some sample code to demonstrate what I've tried:
<<<< edit #2 on April 3 2020
Clarification following hooman182's answer: I have updated my code sample to demonstrate that I am setting requestId
correctly, using a string.
>>>>
try {
// fetch the calendar
$calendar = 'myCalendar';
$calendarObject = $service->calendars->get($calendar);
echo "<pre>";
echo "\nORIGINAL *******************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// set the allowed conferences solutions type
$calendarObject->getConferenceProperties()->setAllowedConferenceSolutionTypes(
array(
"hangoutsMeet",
"eventHangout",
"eventNamedHangout",
)
);
echo "\nUPDATED *******************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// save the changes to the calendar
$calendarObject = $service->calendars->patch($calendar, $calendarObject);;
echo "\nSAVED *********************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// add a createRequest to my event
$event->setConferenceData(new Google_Service_Calendar_ConferenceData(array(
'createRequest' => array(
'requestId' => md5(time()),
'conferenceSolutionKey' => array(
'type' => 'hangoutsMeet',
)
)
)));
// save the event
$event = $service->events->insert($calendar, $event, array(
'conferenceDataVersion' => 1
));
} catch (Google_Service_Exception $e) {
echo "\nERRORS ********************************************************\n\n";
var_dump($e->getErrors());
die;
}
And here is the output of the above:
ORIGINAL *******************************************************
array(1) {
[0]=>
string(12) "eventHangout"
}
UPDATED *******************************************************
array(3) {
[0]=>
string(12) "hangoutsMeet"
[1]=>
string(12) "eventHangout"
[2]=>
string(17) "eventNamedHangout"
}
SAVED *********************************************************
array(1) {
[0]=>
string(12) "eventHangout"
}
ERRORS ********************************************************
array(1) {
[0]=>
array(3) {
["domain"]=>
string(6) "global"
["reason"]=>
string(7) "invalid"
["message"]=>
string(30) "Invalid conference type value."
}
}
Additional details:
Before creating the event you need to use the service account credentials to impersonate a user in your G Suite domain, this way you'll be able to create events with hangoutsMeet
conference type, which is only available for G Suite users.
Even though you service account has domain-wide delegation it doesn't have the same privileges as a G Suite user, from the documentation:
Service accounts are not members of your G Suite domain, unlike user accounts.
In your case, that's why you'd able to create events only with eventHangout
conference type, which is intended for consumers as stated in the documentation for the event resource:
The possible values are:
"eventHangout" for Hangouts for consumers (http://hangouts.google.com)
"eventNamedHangout" for classic Hangouts for G Suite users (http://hangouts.google.com)
"hangoutsMeet" for Hangouts Meet (http://meet.google.com)
"addOn" for 3P conference providers