title: Get Refresh Token in Google OAuth2.0 .NET
body: <p>I have problem using <code>GoogleWebAuthorizationBroker.AuthorizeAsync</code> to authenticate, and looking at some other questions here I went for <code>GoogleAuthorizationCodeFlow</code>. The thing is to use this method I need to get the refresh token.</p>
  
  <p>I have manage to do that following the steps given in <a href="https://stackoverflow.com/questions/5850287/youtube-api-single-user-scenario-with-oauth-uploading-videos/8876027#8876027">this answer</a>, but I haven't find a way of replicating this steps from inside the code in c#.</p>
  
  <p>Is there some way of getting a refresh token and access token using the Google Api?</p>
  
  <p>This is where I need to use it:</p>
  
  <pre><code>ClientSecrets clientSecrets = new ClientSecrets();
  clientSecrets.ClientId = id;
  clientSecrets.ClientSecret = secret;
  String scope = StorageService.Scope.CloudPlatform;
  
  var token = new TokenResponse { RefreshToken = "???" };
  var credentials = new UserCredential(new GoogleAuthorizationCodeFlow(
                  new GoogleAuthorizationCodeFlow.Initializer
                  {
                      ClientSecrets = clientSecrets
                  }),
                  "user",
                  token);
  storageService = new StorageService(new BaseClientService.Initializer()
              {
                  HttpClientInitializer = credentials,
                  ApplicationName = app,
              });
  </code></pre>