【发布时间】:2019-10-04 10:53:31
【问题描述】:
我配置了 IdentityServer4 并尝试使用 jwt 令牌保护 Web API。在这里,当我使用令牌调用 api 时,我得到了
IDX10500:签名验证失败。没有提供用于验证签名的安全密钥。
Web API 我已经注册了如下服务
services
.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = Environment.GetEnvironmentVariable("https://localhost:44394/");
options.RequireHttpsMetadata = false;
options.ApiName = "api1";
});
这是详细日志
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler:信息:无法验证令牌。
Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException:IDX10500:签名验证失败。没有提供安全密钥来验证签名。 在 System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(字符串令牌,TokenValidationParameters 验证参数) 在 System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(字符串令牌,TokenValidationParameters 验证参数,SecurityToken 和验证令牌) 在 Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler:信息:BearerIdentityServerAuthenticationJwt 未通过身份验证。失败消息:IDX10500:签名验证失败。没有提供用于验证签名的安全密钥。
谁能帮我解决这个问题?
【问题讨论】:
标签: c# asp.net-core jwt identityserver4 asp.net-core-webapi