【问题标题】:Flutter App + Google Calendar API : events.insert not returning 'conferenceData'Flutter App + Google Calendar API:events.insert 不返回 \'conferenceData\'
【发布时间】:2022-08-14 13:50:25
【问题描述】:

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

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

但是,返回的事件没有我可以从中获取 \'conferenceId\' 以创建 google meet 链接的 \'conferenceData\'。

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

       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 的任何建议?

*** 编辑 ****

在我四处挖掘时出现了其他东西:

虽然这对我的用例无关紧要,但 google api 不允许我添加与会者 - 即使它是服务帐户电子邮件 ID。

创建事件DetailedApiRequestError时出错(状态:403,消息: 服务帐户无法邀请没有域范围的与会者 权力下放。)

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

我的理解错了吗?

    标签: flutter google-calendar-api


    【解决方案1】:

    我发现 this answer 可以让你朝着正确的方向前进。您需要在 insert() 方法中添加 conferenceData.createRequest 值,以便从新活动中获取 Google Meet 链接。

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

    当服务帐户未模拟 Google Workspace 组织中的任何用户时,预计会出现此错误,您可以在“委托域范围权限”下查看来自 Google Developers 的 this section 并尝试更新代码以模拟不同的用户。环顾四周,我发现here 在您的情况下使用服务帐户时可以使用的可选参数是impersonatedUser

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-04
      • 2014-06-18
      • 2016-07-18
      • 1970-01-01
      • 2020-08-07
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多