【问题标题】:Exception not found while performing the request in the service account with the new rooms在新房间的服务帐户中执行请求时未发现异常
【发布时间】:2020-06-11 09:41:26
【问题描述】:

我创建了一个新资源(房间)并尝试将它与我开发的软件一起使用以列出房间的事件。

 GoogleCredential credential;
 string[] scopes = new string[] { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarReadonly };
 using (var stream =
                new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                credential = GoogleCredential.FromStream(stream)
                        .CreateScoped(scopes);
            }

            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Calendar-Project"
            });


            EventsResource.ListRequest request = service.Events.List(googleID);
            Events eventsg = request.Execute();

            .......

使用新房间的日历 ID 我收到“未找到”错误...“旧”房间正常工作。

日历 ID 正确(我确定)。

我注意到它与“旧房间”的 ID 不同:

旧 ID:xxxxxxxxx.it_1884b9j7r3nr4gbanborb21m3jj8i6ga74oj2chh6so34chm@resource.calendar.google.com

新 ID:xxxxxxxxx.it_1889krjg9ra36gtviaih6imjm9tpe@resource.calendar.google.com

【问题讨论】:

  • googlId 是什么?您是否尝试过使用 calendar.list 来查看您可以访问哪些日历?听起来你的服务帐户没有访问权限。
  • 您是如何创建房间及其日历的? old rooms 是什么意思?
  • @DaImTo:你是对的!访问问题!谢谢

标签: c# google-api google-calendar-api google-api-dotnet-client


【解决方案1】:

“未找到”错误通常意味着您正在尝试访问您实际上无权访问的日历。

如果您创建一个 calendar.list,您可以查看您可以访问哪些日历,然后使用它而不是您的 googleId。

您还可以使用术语“主要”来表示当前经过身份验证的用户的主日历。这也是他们的电子邮件地址。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多