title: How do I get OpenId Connect access token and refresh tokens in ASP.NET MVC 5?
body: <p>I am using the Microsoft.Security.Owin.OpenIdConnect to implement Single Sign-On in my ASP.NET MVC 5 app. This is the code I am using:</p>
  
  <pre><code>app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions {
                  ClientId = "id",
                  ClientSecret = "secret",
                  MetadataAddress = "https://accounts.google.com/.well-known/openid-configuration",
                  RedirectUri = "http://localhost:****",
                  ResponseType = "code id_token",
                  Scope = "openid email profile",
                  SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie
              });
  </code></pre>
  
  <p>However, I want to get the access token, and if necessary the refresh token, to use for API codes. There is very little documentation for how to do this. Apparently I need to use <code>AcquireTokenByAuthorizationCode</code>, but I can only find this function in an ActiveDirectory assembly, which doesn't seem like it is something that would be used for OpenId. How do I set the options so I can get the access token to use in APIs?</p>