I am trying to create a video call in google calendar but the ConferenceData data arrives empty because none has been created, also when I add participants I get the error: The service calendar has thrown an exception. HttpStatusCode is Forbidden. Service accounts cannot invite attendees without Domain-Wide Delegation of Authority. But I have added the service account id to the domain in google Workspace.
Otherwise it works correctly, the calendar is created when I don't add attendees due to the exception produced by the API.
Public Function createMeeting(meetInfo As Meetinfo) As IHttpActionResult
Try
' Se obtienen las credenciales iniciando sesion automaticamente con el usuario establecido
Dim credential As GoogleCredential = GetCredentials()
' Se crea el servicio de Google Calendar
Dim calendarService As New CalendarService(New BaseClientService.Initializer() With {.HttpClientInitializer = credential, .ApplicationName = "xxxx"})
' Creamos el evento de Google Calendar con la reunión de meet
Dim meetingEvent As New [Event] With {
.Summary = meetInfo.meetingTitle,
.Location = "Google Meet",
.Description = meetInfo.meetingDescription,
.ConferenceData = New ConferenceData() With {
.CreateRequest = New CreateConferenceRequest() With {
.RequestId = Guid.NewGuid().ToString()
}
},
.AnyoneCanAddSelf = True
}
Dim startTime As New EventDateTime()
startTime.DateTime = meetInfo.meetingDate
Dim endTime As New EventDateTime()
endTime.DateTime = meetInfo.meetingDate.AddHours(1)
meetingEvent.Start = startTime
meetingEvent.End = endTime
' Añadimos los participantes
Dim attendeesList As New List(Of EventAttendee)()
For Each attendee As String In meetInfo.attendees
Dim attendeeObject As New EventAttendee()
attendeeObject.Email = attendee
attendeesList.Add(attendeeObject)
Next
meetingEvent.Attendees = attendeesList
' Insertamos el evento en Google Calendar.
Dim calendarId As String = ConfigurationManager.AppSettings("meetCalendarId")
Dim request As EventsResource.InsertRequest = calendarService.Events.Insert(meetingEvent, calendarId)
request.ConferenceDataVersion = 1
'request.SendNotifications = True
Dim result As [Event] = request.Execute()
' Recuperamos el link de la reunión de meets
Dim meetLink As String = Nothing
If result.ConferenceData IsNot Nothing Then
For Each entryPoint In result.ConferenceData.EntryPoints
If entryPoint.EntryPointType = "video" Then
meetLink = entryPoint.Uri
Exit For
End If
Next
End If
Return Ok(meetLink)
Catch ex As Exception
Return InternalServerError(ex)
End Try
End Function
(https://i.stack.imgur.com/NpCMf.png) (https://i.stack.imgur.com/NpKWP.png)(https://i.stack.imgur.com/YgU1B.png)
If you have configured domain wide delegation. You need to remember to use Create with user to denote the user who you want to impersonate when you are making the call.