Flutter App + Google Calendar API : events.insert not returning 'conferenceData'

Viewed 123

I am following this github code as an example to create a google calendar event in a workspace calendar using a service account.

I followed various examples on how to authenticate and connect using a service account and now I am able to create an event and it shows up in the workspace calendar as well successfully.

However, the event that is returned does not have the 'conferenceData' from which I could fetch the 'conferenceId' to create the google meet link.

Below is the insert code that I use, which works but does not return the said conference data.

       await calendar.events.insert(event, calendarId,
              conferenceDataVersion: 1, sendUpdates: "none")
          .then((value) {
            print("Event Status: ${value.status}");
            if (value.status == "confirmed") {
              print(value.toJson().toString());
              String joiningLink;
              String eventId;

              eventId = value.id; 
              joiningLink = "https://meet.google.com/${value.conferenceData?.conferenceId}";
            
              print('Event added to Google Calendar : $joiningLink');
            }
           }
          });

Here's the output I get printed to the console:

I/flutter ( 2934): Event Status: confirmed
I/flutter ( 2934): {created: 2022-07-26T16:12:20.000Z, creator: Instance of 'EventCreator', description: xxxx-desc, end: Instance of 'EventDateTime', etag: "3317703881666000", eventType: default, htmlLink: https://www.google.com/calendar/event?eid=djc1b2gyY3RzZ2p1YWGo4aWtmdWIydG5pZ3R2aGNvNEBn, iCalUID: v75oh2ctsgjuahtircv@google.com, id: v75oh2ctv7itndnc, kind: calendar#event, location: Google Meet, organizer: Instance of 'EventOrganizer', reminders: Instance of 'EventReminders', sequence: 0, start: Instance of 'EventDateTime', status: confirmed, summary: xxxxxxx, updated: 2022-07-26T16:12:20.833Z}
I/flutter ( 2934): Event added to Google Calendar : https://meet.google.com/null

Any suggestions on how to get the conferenceData and hence the conferenceId?

*** EDIT ****

Something else turned up while I was digging around:

While it doesn't matter for my use case, but google api won't allow me to add attendees - even if it is the service account email id.

Error creating event DetailedApiRequestError(status: 403, message: Service accounts cannot invite attendees without Domain-Wide Delegation of Authority.)

I don't understand, domain-wide delegation is already done for this account and that is why I am able to authenticate and create a calendar event in the first place.

Is my understanding wrong?

1 Answers

I found this answer that could get you in the right direction. You need to add the conferenceData.createRequest values in the insert() method in order to get a Google Meet link from the new event.

About the error related to Domain-Wide Delegation:

It is expected to get this error when the service account is not impersonating any user in the Google Workspace organization, you can review this section from Google Developers under "Delegate domain wide authority" and try to update the code in order to impersonate a different user. Looking around I found here that the optional argument that you could when using a service account in your case is impersonatedUser.

Related