I am pretty new to C#, I am very used to python. So what I am trying to do is hard for me to figure out.
Basically I am reading a JWT from a server, and I want to put that information from it into an object.
var handler = new JwtSecurityTokenHandler();
var token = handler.ReadJwtToken(jwtObj.accessToken);
I then run it through a serializer function I found:
var x = JsonConvert.SerializeObject(token.Claims.Select(c => new { c.Type, c.Value }))
which gives an object like
[ { "Type": "firstName", "Value": "Jim"}, {"Type": "lastName": "Halpert" } ... ]
But my object i want has attributes firstName and lastName. This seems very simple, but I cannot for the life of me figure out how to get it in the object. I have tried various methods but just assume that I ended here.
any idea what I can do?
Simple. token.Claims.ToDictionary(c => c.Type, c => c.Value)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments