我正在为我的 ASP.NET Web API 使用 Json Web Tokens ... 和 thinktectures 身份模型。
因此,在我的 web api Startup.cs 中,我调用了 IdentityModelJwtBearerAuthenticationExtensions 扩展方法,如下所示:
app.UseJsonWebToken(
issuer: Constants.IssuerName,
audience: Constants.Audience,
signingKey: Constants.SigningKey
);
然后我用 AuthorizeAttribute 装饰我的 API 控制器。
好的,太好了!都好。
但是当令牌过期时......我得到的只是未经授权的401。
我想让 JwtSecurityTokenHandler 中的 SecurityTokenValidationException(“生命周期验证失败。令牌已过期”)冒泡并在 Web API 中可见。
我怎么做?
我环顾四周,看不到正确的方向。
它与 JwtBearerAuthenticationOptions 有关吗?
为任何智慧干杯。