3

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...

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Quoted
  • 31
  • 4

1 Answers1

3

"Invalid conference type value"

Means that you are sending a conference type

$solution_key->setType("hangoutsMeet");

Which is not allowed for the calendar you are using

$google_calendar_id,

Try and run a calendar.get and send the calendar id you are trying to use.

Request:

 $service->calendar->get($google_calendar_id)

Response:

{
 "kind": "calendar#calendar",
 "etag": "\"j3g2ipQvsbvz0_YlxYi3Ml2Fd7A\"",
 "id": "xxxxx@gmail.com",
 "summary": "Linda Lawton ",
 "description": "test",
 "timeZone": "Europe/Copenhagen",
 "conferenceProperties": {
  "allowedConferenceSolutionTypes": [
   "hangoutsMeet"
  ]
 }
}

The allowedConferenceSolutionTypes in the response will tell you which type you are allowed to use for that calendar.

As far as the service account goes just make sure you have domain wide delegation set up and that you are delegating to a user on the domain and this shouldn't be any issues.

$client->setSubject($user_to_impersonate);
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thank you for your answer. I'm also having problems getting the allowedConferenceSolutionTypes with the Calendar API. Is there a function to do that like `$calendarListEntry->getSummary();` ? – Quoted Sep 01 '21 at 19:19
  • you want to get the calendar not the calendar list . [calendar.get](https://developers.google.com/calendar/api/v3/reference/calendars/get) calendarlist is just the UI element at the bottom left of of the google calendar website. You need to get the information on the calendar itself. – Linda Lawton - DaImTo Sep 01 '21 at 19:56
  • How can you adapt `allowedConferenceSolutionTypes` , if I may ask? I'm having [similar issues](https://stackoverflow.com/questions/75916295/google-calendar-api-create-event-google-meet-link/75916596#75916596) – DevelJoe Apr 03 '23 at 12:33