我们正在使用Web API 2和OWIN承载身份验证 . 在我们的OAuthAuthorizationProvider类中,我们以正常方式添加声明 .

OnGrantResourceOwnerCredentials = async context =>
{

//Authenticate the user
//Our logic removed

//After authenticating, set up the claims
var claimsIdentity = new ClaimsIdentity(context.Options.AuthenticationType);
claimsIdentity.AddClaim(new Claim("user", authenticatedUser.Username));
context.Validated(claimsIdentity);

}

我的问题 - is the generated bearer token encrypted by default? 此外,由于它可能是相关的,使用 context.Validated(authenticationTicket) 是否有任何优势?