title: Google service object for Google Calendar API
body: <p>I am trying to use the Google Calendar API in .NET, specifically I am trying to get a list of events. According to the examples <a href="https://developers.google.com/google-apps/calendar/v3/reference/events/list" rel="nofollow">here</a>, in different programming languages I need to create a 'service' object and an 'event' object. However, I can't find a clear explanation of what either of these objects is or how to initiate them. Does anyone have an explanation? Or can anyone provide any information or give me a link to where this is explained? It doesn't necessarily have to be in .NET</p>
  
  <p>Here is the example in Java:</p>
  
  <pre><code>String pageToken = null;
  do {
     events = service.events().list('primary').setPageToken(pageToken).execute();
  List&lt;Event&gt; items = events.getItems();
  for (Event event : items) {
    System.out.println(event.getSummary());
  }
  pageToken = events.getNextPageToken();
  
  } while (pageToken != null); 
  </code></pre>
  
  <p>Following the advice answered, I am getting the following error:</p>
  
  <p><code>Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</code></p>
  
  <p>Here is the code, the error occurs on the <code>credentials = Await...</code> line</p>
  
  <pre><code>Dim credential As UserCredential
  Dim clientSecretsPath As String = Server.MapPath("~/App_Data/client_secret.json")
  Dim scopes As IList(Of String) = New List(Of String)()
      scopes.Add(CalendarService.Scope.Calendar)
  
  Using stream = New System.IO.FileStream(clientSecretsPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
  credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes, "user", CancellationToken.None)
      End Using
  </code></pre>