首页 > 解决方案 > .NET 5 Core API 中的 Google Calendar v3 应用程序可能出了什么问题,它会在一年以上的正常运行时间后突然停止工作?

问题描述

我首先通过在执行请求后停止应用程序的任何结果处理来验证失败是由于执行以下 ListRequest 直接导致的:

EventsResource.ListRequest(builder.GetCalendarService(), "user@domain.com") { Key = "API_KEY", TimeMin = DateTime.Now.AddDays(-3), TimeMax = DateTime.Now.AddDays(21), ShowDeleted = false, SingleEvents = true, OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime };

所有其他请求也已停止工作。构建 GoogleCredential 和 CalendarService 执行没有错误,除非它在实际请求执行之前不执行:

string[] Scopes = {
                CalendarService.Scope.Calendar,
                CalendarService.Scope.CalendarEvents,
                CalendarService.Scope.CalendarEventsReadonly};

            FileStream stream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "auth\\apiinfofile.json", FileMode.Open, FileAccess.Read);
            
GoogleCredential credential;
            credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes).CreateWithUser("user@appname.iam.gserviceaccount.com");
   
            CalendarService service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "appname" });

API 最近有没有我不知道的变化?

我正在使用 1.49 版的 Google API 包并尝试更新到 1.55 版,因为据我所知,这是唯一改变的地方,但没有运气。

是否有任何内容将过期或需要更新的内容?

标签: c#google-calendar-apigoogle-workspacegoogle-api-dotnet-clientservice-accounts

解决方案


推荐阅读