如何在webapi中验证Identityserver4令牌验证?

如何在webapi中验证Identityserver4令牌验证?,identityserver4,identityserver3,webapi,Identityserver4,Identityserver3,Webapi,您是否尝试使用web api(.net framework 4.6)进行ID4连接?我将按照下面的教程进行操作,但使用密钥的APIResource无法工作。如果我给出了错误的API资源名称和密码,它也不会给出任何错误 源代码 var IDSBearerOption = new IdentityServerBearerTokenAuthenticationOptions { AuthenticationType = "Bearer", Authority = "ht

您是否尝试使用web api(.net framework 4.6)进行ID4连接?我将按照下面的教程进行操作,但使用密钥的APIResource无法工作。如果我给出了错误的API资源名称和密码,它也不会给出任何错误

源代码

var IDSBearerOption = new IdentityServerBearerTokenAuthenticationOptions
{
AuthenticationType = "Bearer",
Authority = "https://localhost:5000",
ValidationMode = ValidationMode.Local,
RequiredScopes = new[] { "api1" },
PreserveAccessToken = true,
RoleClaimType = "role",
ValidAudiences = new[] { "TestAPI1" } ,
ClientId = "TestAPI1", //api resource name
ClientSecret = "secret1" //api resource secret

};

app.UseIdentityServerBearerTokenAuthentication(IDSBearerOption);
是否可以在webapi.net framework4.6中验证令牌