【发布时间】:2016-09-21 20:37:40
【问题描述】:
我正在从另一个用户管理的 CalendarId 中检索所有事件,并使用 .Net 中的服务器端库 Google.Apis.Calendar.* 在我们的网站上显示它们。自近 2 个月以来,它一直运行良好,但突然停止工作,显示此 error。 问题是服务帐户确实拥有日历中的所有权限(查看所有详细信息),但在执行请求时无故停止工作(request.Execute();)。谁有这个问题的线索?我真的很感激。
public class GCalendarService : Service
{
public GCalendarService(X509Certificate2 certificate, String accountName, String appName) : base(certificate, accountName, appName)
{
this.Scopes = new string[] {
CalendarService.Scope.Calendar, // Manage your calendars
CalendarService.Scope.CalendarReadonly // View your Calendars
};
this.InitializeCredential(certificate);
this.GService = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = this.Credential,
ApplicationName = appName
});
}
/// <summary>
/// Gets all the events based on a period of time
/// </summary>
/// <param name="calendarId">The ID of the calendar to get the events</param>
/// <param name="minDate">The minimun date to request</param>
/// <param name="maxDate">The max date to request</param>
/// <param name="maxEvents">The max amount of events to retrieve</param>
/// <returns></returns>
public Object GetEvents(string calendarId, DateTime? minDate, DateTime? maxDate, int maxEvents)
{
EventsResource.ListRequest request = ((CalendarService)this.GService).Events.List(calendarId);
request.TimeMin = DateTime.Now;
request.ShowDeleted = false;
request.SingleEvents = true;
request.MaxResults = maxEvents;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
return request.Execute();
}
【问题讨论】:
标签: c# google-api google-calendar-api google-api-dotnet-client service-accounts