So, just a general question. From what I have read, it looks like you can add variables to a JWT token. From a controller, how would you go about reading the variable?
I guess I am having a hard time understanding the claims vs. token aspects here.
Here is what I am doing. Generate user token. Debug shows everything is correct at this point:
UserToken.EntityId = model.EntityId;
UserToken.EmailId = model.EmailId;
UserToken.UserName = model.UserName;
UserToken.Id = model.Id;
UserToken.GuidId = Id;
On controller:
If I debug this, claims has everything in it except EntityId. Pretty sure EntityId is going into the token. Is claims not storing the same information as the token? Everything else is the same in claims as when I set a breakpoint while generating a user token.
Thanks.
I guess I am having a hard time understanding the claims vs. token aspects here.
Here is what I am doing. Generate user token. Debug shows everything is correct at this point:
UserToken.EntityId = model.EntityId;
UserToken.EmailId = model.EmailId;
UserToken.UserName = model.UserName;
UserToken.Id = model.Id;
UserToken.GuidId = Id;
On controller:
C#:
var identity = HttpContext.User.Identity as ClaimsIdentity;
if (identity != null)
{
IEnumerable<Claim> claims = identity.Claims;
// or
// var test = identity.FindFirst("EntityId").Value;
}
If I debug this, claims has everything in it except EntityId. Pretty sure EntityId is going into the token. Is claims not storing the same information as the token? Everything else is the same in claims as when I set a breakpoint while generating a user token.
Thanks.