我想在他们成功登录后返回用户名以显示在我的网络应用程序的右上角。我想将它与承载令牌返回的 json 一起发送。为了生成令牌身份验证,我使用了 ASP.NET Web API 和 Owin middlehawe。
{
"access_token": "blah",
"token_type": "bearer",
"expires_in": 599
}
Run Code Online (Sandbox Code Playgroud)
我希望回报是这样的
{
"access_token": "blah",
"token_type": "bearer",
"expires_in": 599,
"displayusername":"Hi Mundo"
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过索赔,但那些并没有给出我想要的结果。
我曾尝试使用 AuthenticationProperties 但不起作用
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
if (validation works)
{
// add claims
var moreInfo = new AuthenticationProperties(new Dictionary<string, string> { { "username", "Don"}, { "Department","MIS"} });
var ticket = new AuthenticationTicket(identity, moreInfo);
context.Validated(ticket);
}
else
{
context.SetError("invalid_grant", "The user name or …Run Code Online (Sandbox Code Playgroud)