【问题标题】:System.InvalidOperationException: You must either set Authority or IntrospectionEndpoint error in .net core 2.2System.InvalidOperationException:您必须在 .net core 2.2 中设置 Authority 或 IntrospectionEndpoint 错误
【发布时间】:2023-02-01 20:45:23
【问题描述】:

正如图片中提到的,我有下面的包但是执行时出现错误

【问题讨论】:

标签: asp.net-core


【解决方案1】:

当使用 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;
        });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    • 1970-01-01
    • 2016-05-09
    相关资源
    最近更新 更多