Google Calendar API - Not Returning From Execute() C#

前端 未结 2 925
情深已故
情深已故 2021-01-25 06:35

Running the code below never returns from the Execute function. I have a private calendar on my personal gmail account that I have shared with the developer.gserviceaccount.com

相关标签:
2条回答
  • 2021-01-25 07:16

    The problem is described more in details in https://github.com/google/google-api-dotnet-client/issues/606. It seems that we currently have a bug in 1.9.3, which is fixed in the github repository (The fix itself is in https://github.com/google/google-api-dotnet-client/pull/612).

    A new release is planned to be in the next few weeks, so stay tuned; http://google-api-dotnet-client.blogspot.com/.

    If meantime you want to play and test it yourself you can use the projects in GitHub with the Calendar Service. It's better for you to download the Calendar Service from https://developers.google.com/resources/api-libraries/download/calendar/v3/csharp to avoid binding redirects. I explained what you have to do in #606 itself.


    Update (Dec 15th): New NuGet packages for 1.10.0 are available, read more about it at: http://google-api-dotnet-client.blogspot.com/2015/12/announcing-release-of-1100.html

    0 讨论(0)
  • 2021-01-25 07:29

    There is a difference between a calendar and calendarlist. In the Google Calendar website calendarlist appears on the left hand side its a list of calendars. However for a calendar to appear on calendarlist it has to be added to the calendarlist.

    You gave your service account access to the calendar but did you programmatically tell it to add the calendar to its calendarlist? You should have used CalendarList: insert

    I am not sure why you want to get the calendarlist. Personally I think you should just go with Calendars: get you already know the ID of the calendar from the google calendar website.

    Tip: Execute is going to return an object I am not sure .ToString() on it is really the best idea.

    update code:

    /// <summary>
            /// Returns metadata for a calendar. 
            /// Documentation:https://developers.google.com/google-apps/calendar/v3/reference/calendars/get
            /// </summary>
            /// <param name="service">Valid Autenticated Calendar service</param>
            /// <param name="id">Calendar identifier.</param>
            /// <returns>Calendar resorce: https://developers.google.com/google-apps/calendar/v3/reference/calendars#resource </returns>
            public static Calendar get(CalendarService service, string id)
            {
                try
                {
                   return service.Calendars.Get(id).Execute();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return null;
                }
            }
    

    code from My sample project on GitHub

    0 讨论(0)
提交回复
热议问题