title: Why am I not receiving a RefreshToken from a Google OAuth request?
body: <p>I am attempting to integrate Google Calendar into my application and I am having some problems with the OAuth authorization passing off a RefreshToken.  I receive an AccessToken with no issue, but the RefreshToken property is null.  See the line marked "ERROR HERE:" for where I am having the issue</p>
  
  <p>My Asp.Net MVC controller (named <code>OAuthController</code>) looks like the following:</p>
  
  <pre><code>    public ActionResult Index()
      {
          var client = CreateClient();
          client.RequestUserAuthorization(new[] { "https://www.googleapis.com/auth/calendar" }, new Uri("http://localhost/FL.Evaluation.Web/OAuth/CallBack"));
  
          return View();
      }
  
      public ActionResult CallBack()
      {
  
          if (string.IsNullOrEmpty(Request.QueryString["code"])) return null;
  
          var client = CreateClient();
  
          // Now getting a 400 Bad Request here
          var state = client.ProcessUserAuthorization();
  
          // ERROR HERE:  The RefreshToken is NULL
          HttpContext.Session["REFRESH_TOKEN"] = Convert.ToBase64String(Encoding.Unicode.GetBytes(state.RefreshToken));
  
          return JavaScript("Completed!");
      }
  
      private static WebServerClient CreateClient()
      {
          return
              new WebServerClient(
                  new AuthorizationServerDescription()
                      {
                          TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token"),
                          AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth"),
                          ProtocolVersion = ProtocolVersion.V20
                      }
                  , _GoogleClientId, _GoogleSecret);
      }
  </code></pre>
  
  <p>I see in Google's API documents, that I need to ensure that the <code>access_type</code> requested is set to <code>offline</code> for a RefreshToken to be sent.  How do I set this value in my Authenticator request?</p>