简体   繁体   English

Flutter 应用程序 + Google 日历 API:events.insert 未返回“会议数据”

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

I am following this github code as an example to create a google calendar event in a workspace calendar using a service account.我以这个 github 代码为例,使用服务帐户在工作区日历中创建谷歌日历事件。

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.但是,返回的事件没有“conferenceData”,我可以从中获取“conferenceId”来创建 google meet 链接。

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:这是我打印到控制台的 output:

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?关于如何获取会议数据和会议 ID 的任何建议?

*** 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.虽然这对我的用例无关紧要,但谷歌 api 不允许我添加与会者 - 即使它是服务帐户 email id。

Error creating event DetailedApiRequestError(status: 403, message: Service accounts cannot invite attendees without Domain-Wide Delegation of Authority.)创建事件DetailedApiRequestError时出错(状态:403,消息:服务帐户无法邀请没有全域授权的与会者。)

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?我的理解错了吗?

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.您需要在insert()方法中添加conferenceData.createRequest值,以便从新活动中获取 Google Meet 链接。

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.当服务帐户未模拟 Google Workspace 组织中的任何用户时,预计会出现此错误,您可以查看 Google Developers 的“委派域范围权限”下的此部分,并尝试更新代码以模拟其他用户. Looking around I found here that the optional argument that you could when using a service account in your case is impersonatedUser .环顾四周,我发现您的案例中使用服务帐户时可以使用的可选参数是impersonatedUser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM