Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

Enabled AuthUsePkce for SwaggerUI but the server returns pkce_missing_challenge

Open babakdevoteam opened this issue 3 years ago • 3 comments

I have already asked this in stackoverflow, but did not get any response.

I am using version v5.0.0 of Swashbuckle in my asp net core 3.1 app :

options.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme
        {
            Type = SecuritySchemeType.OAuth2,

            Flows = new OpenApiOAuthFlows
            {
                AuthorizationCode = new OpenApiOAuthFlow
                {
                    AuthorizationUrl = new Uri("https://my.okta.com/oauth2/v1/authorize"),
                    TokenUrl = new Uri("https://my.okta.com/oauth2/v1/token"),
                    Scopes = new Dictionary<string, string>
                        {
                        { "openid", "desc" }
                        },
                }
            },
            Description = "Balea Server OpenId Security Scheme"
        });
app.UseSwaggerUI(options =>
            {
            options.RoutePrefix = "docs";
          
            options.OAuthScopeSeparator(",");
            options.OAuthUsePkce();
            });

But the Auth server returns error :

pkce_missing_challenge

Here is the request log that Auth server receives :

/oauth2/v1/authorize?response_type=code&client_id=xxxxxxxxxxxxx&redirect_uri=https%3A%2F%2Flocalhost%3A8002%2Fdocs%2Foauth2-redirect.html&scope=openid&state=VHVlIE1hciAwMiAyMDIxIDExOjIyOjM3IEdNVCswMDAwIChXZXN0ZXJuIEV1cm9wZWFuIFN0YW5kYXJkIFRpbWUp

And when I inspect "v1/swagger.json" I do not see "usePkceWithAuthorizationCodeGrant" there.

babakdevoteam avatar Mar 05 '21 12:03 babakdevoteam