title: How Google API V 3.0 .Net library and Google OAuth2 Handling refresh token
body: <p>In my application I am using Google API V 3.0 .Net library with Google OAuth2 to synchronize Google calender and outlook calender. I am using below code to get the Google.Apis.Calendar.v3.CalendarService service object. 
  During authentication I stored the Json file and from that I am requesting for Google.Apis.Auth.OAuth2.UserCredential object.</p>
  
  <pre><code>private Google.Apis.Auth.OAuth2.UserCredential GetGoogleOAuthCredential()
  {
      GoogleTokenModel _TokenData = new GoogleTokenModel();
      String JsonFilelocation = "jsonFileLocation;
      Google.Apis.Auth.OAuth2.UserCredential credential = null;
      using (var stream = new FileStream(JsonFilelocation, FileMode.Open,
                      FileAccess.Read))
      {
          Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
          credential = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync(
          Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(stream).Secrets,
          new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar },
          "user",
          CancellationToken.None,
          new FileDataStore("OGSync.Auth.Store")).Result;
      }
      return credential;
  }
  </code></pre>
  
  <p>Requesting for Service object code is :</p>
  
  <pre><code>Google.Apis.Calendar.v3.CalendarService _V3calendarService = new Google.Apis.Calendar.v3.CalendarService(new Google.Apis.Services.BaseClientService.Initializer()
  {
  HttpClientInitializer = GetGoogleOAuthCredential(),
  ApplicationName = "TestApplication",
  });
  </code></pre>
  
  <p>Above code works fine to get the Calendarservice object. My question is, my Json file has refresh  and access tokens. how the above code handles refresh token to obtain the service when access token expired? Because I need to call the Calendarservice object frequently, I like to implement singleton pattern for calenderService object. How to get Calendarservice without calling GetGoogleOAuthCredential frequently? Any help/guidance is appreciated.</p>