Google Calendar API - Don't Return Using Execute () Function C #

The execution of the code below never returns from the Execute function. I have my own calendar on my personal gmail account, which I shared with the developer.gserviceaccount.com account.

Looking at the API manager, the use / quotes show that I used or even hit the api yet.

Any thoughts appreciated.

using System.Security.Cryptography.X509Certificates; using System.Web; using Google.Apis.Calendar.v3; using Google.Apis.Auth.OAuth2; using Google.Apis.Services; public class GoogleLoginWithServiceAccount { public string getEventList() { var GoogleOAuth2CertificatePath = HttpContext.Current.Server.MapPath("~/xx/xx.p12"); var GoogleOAuth2EmailAddress = " xx-xxxx@developer.gserviceaccount.com "; var GoogleOAuth2PrivateKey = "notasecret"; var certificate = new X509Certificate2(GoogleOAuth2CertificatePath, GoogleOAuth2PrivateKey, X509KeyStorageFlags.Exportable); var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(GoogleOAuth2EmailAddress) { //User = GoogleAccount, Scopes = new string[] { CalendarService.Scope.Calendar } }.FromCertificate(certificate)); // Create the service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Testing" }); var listRequest = service.CalendarList.List(); return listRequest.Execute().ToString(); } } 

I am still facing this problem. I created a simple application to reproduce this, does anyone have any thoughts? dropbox.com/s/g45xcta7ii3hj51/GoogleTestWeb.zip?dl=0

+1
c # google-calendar google-api google-api-dotnet-client
source share
2 answers

The issue is described in more detail at https://github.com/google/google-api-dotnet-client/issues/606 . It looks like we currently have a bug in 1.9.3, which is fixed in the github repository (the fix itself is located at https://github.com/google/google-api-dotnet-client/pull/612 ).

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

If you want to play and test yourself, you can use the projects on GitHub using the calendar service. You better download the calendar service from https://developers.google.com/resources/api-libraries/download/calendar/v3/csharp to avoid link redirects. I explained what you should do in # 606.


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

+1
source share

There is a difference between a calendar and a calendar. The Google Calendar Calendar on the left side of the screen displays a list of calendars. However, to display a calendar in a calendar, it must be added to the list of calendars.

You granted access to the calendar of your service account, but did you programmatically tell her to add the calendar to your calendar list? You should have used CalendarList: insert

I'm not sure why you want a list of calendars. Personally, I think you just need to go with Calendars: get , you already know the calendar id from the Google calendar website.

Tip: Execute will return an object that I'm not sure about. 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 github sample project

enter image description here

0
source share

All Articles