【发布时间】:2023-02-01 20:45:23
【问题描述】:
【问题讨论】:
-
嗨 @sandy,你的 Startup.cs 怎么样?你把
options.ApiSecret加到AddIdentityServerAuthentication了吗?参考:github.com/IdentityServer/IdentityServer4/issues/1745
标签: asp.net-core
【问题讨论】:
options.ApiSecret加到AddIdentityServerAuthentication了吗?参考:github.com/IdentityServer/IdentityServer4/issues/1745
标签: asp.net-core
当使用 IdentityServer 身份验证将格式错误的 JWT 传递给 .NET Core 2.0 API 并返回 500 状态代码而不是 401 时,设置 options.SupportedTokens = SupportedTokens.Jwt;在 Startup.cs ConfigureServices() 中解决了这个问题。 Source
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = configuration["Authorization:Authority"];
options.ApiName = configuration["Authorization:Audience"];
options.EnableCaching = true;
options.CacheDuration = TimeSpan.FromHours(1);
options.SupportedTokens = SupportedTokens.Jwt;
});
【讨论】: