title: How to access to Swashbuckle.AspNetCore protected api to test auto-documentation?
body: <p>I'm developing a solution with IdentityServer4, a protected web api and a consumer (console app to testing).</p>
  
  <p>I use Swashbuckle.AspNetCore package to auto-document my web api.</p>
  
  <p>In my <strong>ConfigureServices</strong> method in the web api I write this code:</p>
  
  <pre><code>services.AddSwaggerGen(c =&gt;
          {
              c.SwaggerDoc("v1", new Info { Title = "API v1", Version = "v1" });
              c.SwaggerDoc("v2", new Info { Title = "API v2", Version = "v2" });
              c.AddSecurityDefinition("oauth2", new OAuth2Scheme()
              {
                  AuthorizationUrl = "http://localhost:5000/connect/authorize",
                  Flow = "accessCode",
                  TokenUrl = "http://localhost:5000/connect/token",
                  Scopes = new Dictionary&lt;string, string&gt; { { "api1", "My API" } }
              });
              c.OperationFilter&lt;AuthorizationHeaderParameterOperationFilter&gt;();            
          });
  </code></pre>
  
  <p>When I click to <em>authorize</em> button in Swagger.UI page, I redirect to IdentityServer and here I enter user credentials and it works.
  So now I have to enter access token (in Swagger.UI page) to access to my protected endpoint to see documentation:</p>
  
  <pre><code>[ApiExplorerSettings(GroupName = "v2")]
  public class ValuesController : Controller
  {
      [HttpGet("[controller]")]
      [Authorize]
      public async Task&lt;IEnumerable&lt;string&gt;&gt; GetAsync()
      {
          var accessToken = await HttpContext.Authentication.GetTokenAsync("access_token");
          return new string[] { "value1", "value2" };
      }
  }
  </code></pre>
  
  <p>But <strong>where is the access token saved?</strong>  If I call my api and I put a breakpoint I have the access token in <em>accessToken</em> variable.
  I think it should do valorized automatically the access token in authorization header? What are the steps?</p>
  
  <p>Thanks in advance</p>