Hey there,
I need to pass some custom information with my JSON Web Token in asp.net web api.
Right now it only returns access_token,expires_in and token_type properties but I need to pass some additional information along with those properties like user_name,user_roles etc. I now the json token contains these information in encoded format but as my api will be consume by other platforms like android and ios so, I need to pass these information in plain text format.
Currently I am using following code to pass custom information with JSON token but I am getting same response as before.
Dictionary<string,> d = new Dictionary<string,>();
d.Add("user_name", user.UserName);
var props = new AuthenticationProperties(d);
ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, "JWT");
var ticket = new AuthenticationTicket(oAuthIdentity, props);
context.Validated(ticket);
Below is the response of my web api:-
{
access_token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1laWQiOiIxNzViNzAxNC03M2YwLTQzNjctOGE0NC1iNmMxZjczNjc1MzAiLCJ1bmlxdWVfbmFtZSI6IkFkbWluIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9hY2Nlc3Njb250cm9sc2VydmljZS8yMDEwLzA3L2NsYWltcy9pZGVudGl0eXByb3ZpZGVyIjoiQVNQLk5FVCBJZGVudGl0eSIsIkFzcE5ldC5JZGVudGl0eS5TZWN1cml0eVN0YW1wIjoiYjdjMzQ5MmEtMDRmZC00OTQwLThjZDktYjEzMWRmNjFmMzIyIiwicm9sZSI6WyJVc2VyIiwiUHVibGlzaGVyIiwiQWRtaW4iXSwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo1OTgyMiIsImF1ZCI6IjEyMzQ1Njc4IiwiZXhwIjoxNDc2NDUzNzI3LCJuYmYiOjE0NDUzNDk3Mjd9.wxstrUpUZSD1v5t1-F5_DVBrqpD7Yxq5Tsx6bnugVYQ"
token_type: "bearer"
expires_in: 31103999
}