title: Web API with OAUTH using Swagger / Swashbuckle
body: <p>I am trying to get my Web API project to use Swagger 'pretty' documentation, etc. (<a href="http://swagger.io/" rel="nofollow noreferrer">http://swagger.io/</a>)</p>
  
  <p>I'm using Swashbuckle for .NET, installed from NuGet and the version I am using is 4.0.1</p>
  
  <p>I've been able to install and use Swagger. Everything seems normal at this point. The only hurdle I have is to disable API key's and have the ability to use OAuth, like in the PetStore sample (<a href="http://petstore.swagger.wordnik.com/#!/pet/addPet" rel="nofollow noreferrer">http://petstore.swagger.wordnik.com/#!/pet/addPet</a>)</p>
  
  <p>I've tried everything I could find on the web. Let me list them below:</p>
  
  <p>First, Here is my Startup.cs</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
  {
      var config = new HttpConfiguration();
  
      WebApiConfig.Register(config);
  
      Swashbuckle.Bootstrapper.Init(config);
  }
  </code></pre>
  
  <p>Now, my SwaggerConfig.cs:</p>
  
  <pre><code>public static void Register()
  {
      Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);
  
      SwaggerSpecConfig.Customize(c =&gt;
      {
          c.IgnoreObsoleteActions();
  
          c.IncludeXmlComments(GetXmlCommentsPath());
  
          c.ApiInfo(new Info
          {
              Title = "Work you",
              Description = "testing some stuffs",
              Contact = "Email@email.com"
          });
  
          c.Authorization("oauth2", new Authorization
          {
              Type = "oauth2",
              Scopes = new List&lt;Scope&gt;
                  {
                      new Scope { ScopeId = "products.read", Description = "View products" },
                      new Scope { ScopeId = "products.manage", Description = "Manage products" }
                  },
              GrantTypes = new GrantTypes
              {
                  ImplicitGrant = new ImplicitGrant
                  {
                      LoginEndpoint = new LoginEndpoint
                      {
                          Url = "https://www.mysecure.website.com"
                      },
                      TokenName = "access_token"
                  }
              }
          });
      });
  
  
      SwaggerUiConfig.Customize(c =&gt;
      {
          c.EnableOAuth2Support("client_id", "test-realm", "app Name");
  
          var thisAssembly = typeof(SwaggerConfig).Assembly;
  
          c.SupportHeaderParams = true;
          c.DocExpansion = DocExpansion.List;
          c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
          c.EnableDiscoveryUrlSelector();
  
      });
  
  }
  </code></pre>
  
  <p>I have a SwaggerExtensions folder, in there I have the files that should be required. For example:</p>
  
  <p><img src="https://i.stack.imgur.com/7qr4J.png" alt="Files for SwaggerExt"></p>
  
  <p>I have classes decorated with: </p>
  
  <pre><code>[ScopeAuthorize("this.scope")]
  </code></pre>
  
  <p>However, the OAuth option never displays for me on the swagger page. I can't see where I am supposed to be able to enter custom headers either.</p>
  
  <p>I do see the title and documentation description, email address, etc is being read from the SwaggerConfig.cs so I know its at least being read.</p>
  
  <p>I can't figure it out. :(</p>
  
  <p>Any ideas?</p>