I'm using JWT tokens and OpenIdConnectServer. All works very well, but i can't add custom properties in token response... Here are the result:
resource": "resource_server_1",
"token_type": "bearer",
"access_token": "eyJhb....LSk5PQldEVVFaTllNU",
"expires_in": "3600"
I want to add some properties like username or role... I'm trying to add through AuthenticationProperties, but it is doesn't work. Here my code:
public override Task GrantResourceOwnerCredentials(GrantResourceOwnerCredentialsContext context)
{
ClaimsIdentity identity = new ClaimsIdentity(OpenIdConnectServerDefaults.AuthenticationScheme);
identity.AddClaim(ClaimTypes.Name, "test", "token id_token");
identity.AddClaim(ClaimTypes.Role, "test", "token id_token");
var ticket = new AuthenticationTicket(
new ClaimsPrincipal(identity),
new AuthenticationProperties(new Dictionary<string, string>
{
{"username", "test" }
}),
context.Options.AuthenticationScheme);
ticket.SetResources(new[] { "resource_server_1" });
context.Validated(ticket);
return Task.FromResult<object>(null);
}