laravelgoogle-calendar-apigoogle-contacts-apigoogle-meet

How to create a Google calendar event with hangoutLink (Google meet)


i'am using spatie/laravel-google-calendar package to create event with meeting but it only create event without meeting, i merged this commit

but it didn't work 'still create event without meeting'.
this is createFromGoogleCalendarEvent method of event.php file

public static function createFromGoogleCalendarEvent(Google_Service_Calendar_Event $googleEvent, $calendarId)
    {

        // this option are to create a conference and add a link to meet in event
        $googleCalendar = static::getGoogleCalendar($calendarId);
        $service = $googleCalendar->getService();
        $conference = new \Google_Service_Calendar_ConferenceData();
        $conferenceRequest = new \Google_Service_Calendar_CreateConferenceRequest();
        $conferenceRequest->setRequestId('randomString123');
        $conference->setCreateRequest($conferenceRequest);
        $googleEvent->setConferenceData($conference);
        $googleEvent = $service->events->patch($calendarId, $googleEvent->id, $googleEvent, ['conferenceDataVersion' => 1]);

        $event = new static;

        $event->googleEvent = $googleEvent;
        $event->calendarId = $calendarId;

        return $event;
    }

and this is my code to create event

$event = new Spatie\GoogleCalendar\Event;
$event->name = 'A new event';
$event->description = 'Event description';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();
$event->save();

and this is my response

{
  anyoneCanAddSelf: null,
  attendeesOmitted: null,
  colorId: null,
  created: "2021-04-06T11:54:35.000Z",
  description: "Event description",
  endTimeUnspecified: null,
  etag: ""3235420151680000"",
  eventType: "default",
  guestsCanInviteOthers: null,
  guestsCanModify: null,
  guestsCanSeeOtherGuests: null,
  hangoutLink: null,
  htmlLink: "https://www.google.com/calendar/event?eid=dXZyNHByamc0ZXNqbDkxajI5c3I0cWI3c28gZGxvcW45M2VoOWlsZm5lOWRjb2xodDY5aWtAZw",
  iCalUID: "uvr4prjg4esjl91j29sr4qb7so@google.com",
  id: "uvr4prjg4esjl91j29sr4qb7so",
  kind: "calendar#event",
  location: null,
  locked: null,
  privateCopy: null,
  recurrence: null,
  recurringEventId: null,
  sequence: 0,
  status: "confirmed",
  summary: "A new event",
  transparency: null,
  updated: "2021-04-06T11:54:35.840Z",
  visibility: null,
  creator: {
    displayName: null,
    email: "mohamed-service-account@mohamed-project.iam.gserviceaccount.com",
    id: null,
    self: null
  },
  organizer: {
    displayName: "Mohamed calendar",
    email: "dloqn93eh9ilfne9dcolht69ik@group.calendar.google.com",
    id: null,
    self: true
  },
  start: {
    date: null,
    dateTime: "2021-04-06T13:54:35+02:00",
    timeZone: null
  },
  end: {
    date: null,
    dateTime: "2021-04-06T14:54:35+02:00",
    timeZone: null
  },
  reminders: {
    useDefault: true
  }
}

Solution

  • I resolved this issue by replacing service account authentication with oauth.