在我的asp net核心3.0应用程序中,我使用了Swashbuckle版本的5.0.0版本:
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();
});但是Auth服务器返回错误:
pkce_missing_challenge
以下是Auth服务器接收的请求日志:
/oauth2/v1/authorize?response_type=code&client_id=xxxxxxxxxxxxx&redirect_uri=https%3A%2F%2Flocalhost%3A8002%2Fdocs%2Foauth2-redirect.html&scope=openid&state=VHVlIE1hciAwMiAyMDIxIDExOjIyOjM3IEdNVCswMDAwIChXZXN0ZXJuIEV1cm9wZWFuIFN0YW5kYXJkIFRpbWUp
发布于 2021-03-05 21:12:01
因此,由于这,我没有使用"Pkce“,而是使用了以下配置
options.AddSecurityDefinition("OAuth2", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows
{
Implicit = new OpenApiOAuthFlow
{
AuthorizationUrl = new Uri($"mydomain.com/oauth2/default/v1/authorize"),
TokenUrl = new Uri($"mydomain.com/oauth2/default/v1/token"),
Scopes = new Dictionary<string, string>
{
{ "openid", "test" },
},
}
},
});https://stackoverflow.com/questions/66438535
复制相似问题