I am using Web Api 2 and implemented custom token based authentication. It is working fine but I want to get few extra properties values in response. Even though I have added new claims and also added new properties to get their values in response but I am still get only three values in response which are 'access_token', "token_type" and "expires_in". How can I get more values in response. This is my code:
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
if(context.UserName == "user" && context.Password=="user")
{
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
identity.AddClaim(new Claim(ClaimTypes.Role, "Administrators"));
identity.AddClaim(new Claim("MyClaim", "I don't know"));
var props = new AuthenticationProperties(new Dictionary<string, string>
{
{ "name", "John" },
{ "surname", "Smith" },
{ "age", "40" },
{ "gender", "Male" }
});
var ticket = new AuthenticationTicket(identity, props);
context.Validated(ticket);
}
else
{
context.SetError("Invalid_Grant", "Provided username and password is incorrect");
return;
}
}
This is the output I am getting
{
"access_token": "xxxxx", "token_type": "bearer", "expires_in": 86399 }