Swashbuckle.webapi: Swashbuckle 5.0 and Password Grant Flow

Created on 23 Feb 2015  路  10Comments  路  Source: domaindrivendev/Swashbuckle.WebApi

There is documentation on how to authenticate request with the Implicit Grant Flow but not with the Password Grant Flow. Based on the doc for the implicit grant I've enable swagger like this

Swashbuckle.Application.SwaggerEnabledConfiguration sec = config.EnableSwagger(c =>
      {
        c.SingleApiVersion("v1", "MyApi");

        c.OAuth2("oauth2")
          .Description("OAuth2 Password Grant")
          .Flow("password")
          .Scopes(scopes => { scopes.Add("read", "Read access to protected resources"); })
          .TokenUrl("http://localhost:51398/OAuth/token");
        c.OperationFilter<AssignOAuth2SecurityRequirements>();

        c.IncludeXmlComments(System.String.Format(@"{0}\bin\MyApi.XML", System.AppDomain.CurrentDomain.BaseDirectory));
      });

      sec.EnableSwaggerUi();

I took the "AssignOAuth2SecurityRequirements" extension under SwahsBuckle.Dummy.Core.
Is there any other extensions needed for the Password Flow?

Most helpful comment

@domaindrivendev It looks like Password Flow support has landed in swagger-ui Master: https://github.com/swagger-api/swagger-ui/pull/2397

Are there any changes that need to be done in Swashbuckle to include this?

All 10 comments

As far as I can tell, the OAuth2 "Password flow" is not currently supported by the swagger-ui

https://github.com/swagger-api/swagger-ui/issues/807

So, you can describe it in the spec (as you appear to be doing above) but you won't get any of the additional UI goodness. But, SB does allow you to a) inject your own JavaScript or b) inject your own version of index.html so if you were willing, you could theoretically build in the UI workflow yourself ...

Hi @domaindrivendev is this still not available yet? I was hoping to be able to support this flow on the UI level too.

@domaindrivendev I second the request by @tjoudeh this will be a much appreciated feature.

I just develop my web api documentation using swashbuckle 5 but I think I will use another previous version because I need this feature.

@domaindrivendev @tjoudeh Any update on this?

@domaindrivendev It looks like Password Flow support has landed in swagger-ui Master: https://github.com/swagger-api/swagger-ui/pull/2397

Are there any changes that need to be done in Swashbuckle to include this?

@domaindrivendev I'd appreciate a response to my comment above.

This would interest me, too.

I am also interested in the latest version of swagger ui. I believe the current version is 3.0.9 and seems to add additional support for the OAuth forms.

Does anyone have some documentation on how to implement password flow in .NET Framework (rather than .NET Core).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rautsik picture rautsik  路  4Comments

nf17 picture nf17  路  4Comments

niemyjski picture niemyjski  路  3Comments

josephearl picture josephearl  路  4Comments

johnpmcclung picture johnpmcclung  路  3Comments