我不知道其他中间件,但JWT承载认证允许为每个请求保存令牌。但这需要激活(在StartUp.ConfigureServices(...
)。
services
.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options => options.SaveToken = true);
然后可以通过访问实际的令牌(以其所有的神秘形式)作为字符串(或null)
HttpContext.GetTokenAsync("Bearer", "access_token")