小编Hay*_*n L的帖子

Identity Server 4 Swagger身份验证

我目前在使用swagger授权api调用身份服务器4时遇到问题.
我的swagger依赖是使用swashbuckle版本-beta客户端对象在身份服务器4中看起来像

new Client
{
    ClientId="swagger",
    Enabled = true,
    ClientName="Swagger",
    AllowedGrantTypes = GrantTypes.Implicit,
    ClientSecrets = new List<Secret>
    {
        new Secret("secret".Sha256())
    },
    AllowedScopes = new List<string>
    {
        "apil"
    },
    RedirectUris = new List<string>
    {
        "http://localhost:15138/swagger/ui/popup.html"
    },
    AllowedCorsOrigins = new List<string>
    {
        "http://localhost:15138",
        "http://localhost:15138"
    },
    AllowAccessTokensViaBrowser = true,
    AllowAccessToAllScopes= true
}
Run Code Online (Sandbox Code Playgroud)

客户端对象是身份验证的配置方法中的身份服务器4模型

app.UseIdentityServer();
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
    Authority = "http://localhost:15138/",
    ScopeName = "apil",
    RequireHttpsMetadata = false,

});
Run Code Online (Sandbox Code Playgroud)

使用fiddler我的get请求看起来像这样

GET /connect/authorize?state=9321480892748389&nonce=5279296493808222&client_id=swagger&redirect_uri=http%3A%2F%2Flocalhost%3A15138%2Fswagger%2Fui%2Fpopup.html&response_type=id_token%20token&scope=apil HTTP/1.1

所有必要的参数都在那里,客户端具有相应的客户端ID,但我得到的响应是重定向到错误页面,其中包含无效请求的消息.我期待一个登录页面传递凭据或类似的东西获得授权我想知道我做错了什么.

c# swagger .net-core swashbuckle identityserver4

4
推荐指数
1
解决办法
5310
查看次数

标签 统计

.net-core ×1

c# ×1

identityserver4 ×1

swagger ×1

swashbuckle ×1