Jwt Identityserver4保护webapi不工作

Jwt Identityserver4保护webapi不工作,jwt,identityserver4,webapi,.net-framework-version,Jwt,Identityserver4,Webapi,.net Framework Version,我已经实现了发布jwt令牌的identity server。我想保护在.NETFramework4.6中开发的API 客户端应用程序(角度) AccessTokenTypes=jwt AllowedScopes=openid配置文件脱机访问api1 AllowedGrantTypes=代码 API var IDSBearerOption = new Microsoft.Owin.Security.Jwt.JwtBearerAuthenticationOptions {

我已经实现了发布jwt令牌的identity server。我想保护在.NETFramework4.6中开发的API

客户端应用程序(角度)

  • AccessTokenTypes=jwt
  • AllowedScopes=openid配置文件脱机访问api1
  • AllowedGrantTypes=代码
API

var IDSBearerOption = new Microsoft.Owin.Security.Jwt.JwtBearerAuthenticationOptions
            {

                TokenValidationParameters = new TokenValidationParameters()
                {
                    //ValidAudience = "https://localhost:5001" ,
                    //ValidIssuer = "testResource" ,
                    //SaveSigninToken =true,
                    RoleClaimType = "role",

                    ValidateIssuer = true,
                    ValidateAudience = true,
                    //ValidateIssuerSigningKey = false,
                    ValidIssuer = "testResource",
                    ValidAudience = "https://localhost:5001",
                    

                },
                AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active

            };
            app.UseJwtBearerAuthentication(IDSBearerOption);
无法访问Authrozie属性方法获取错误“此请求的授权已被拒绝”
请帮忙。可以找到完整的源代码

您知道id服务器中使用的IdentityServer4版本吗?你能展示一下客户端配置吗?当你说代码时,你是指“授权代码”吗?