颤振应用程序 + 谷歌日历 API:事件插入不返回'conferenceData'



我以github代码为例,使用服务帐户在工作区日历中创建谷歌日历事件。

我遵循了关于如何使用服务帐户进行身份验证和连接的各种示例,现在我可以创建一个事件,它也成功地显示在工作区日历中。

然而,返回的事件没有"conferenceData",我可以从中获取"conferencyId"来创建谷歌会议链接。

下面是我使用的插入代码,它可以工作,但不会返回所述会议数据。

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');
}
}
});

这是我打印到控制台的输出:

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

关于如何获得会议数据以及会议ID,有什么建议吗?

***编辑***

当我四处挖掘时,发现了其他东西:

虽然这对我的用例来说并不重要,但谷歌api不允许我添加与会者,即使是服务帐户的电子邮件id。

创建事件DetailedApiRequestError时出错(状态:403,消息:服务帐户无法邀请没有Domain Wide的与会者授权。(

我不明白,已经为此帐户完成了域范围的委派,这就是为什么我能够首先验证并创建日历事件。

我的理解错了吗?

我找到了这个答案,它可以让你朝着正确的方向前进。您需要在insert()方法中添加conferenceData.createRequest值,以便从新事件中获得Google Meet链接。

关于与域委派相关的错误:

当服务帐户没有模拟谷歌工作区组织中的任何用户时,预计会出现此错误,您可以在";委派域范围的权限";并尝试更新代码以模拟不同的用户。环顾四周,我发现在您的情况下使用服务帐户时可以使用的可选参数是impersonatedUser

最新更新