How to add UserId to claim


ClaimsIdentity claimsIdentity = new ClaimsIdentity(new
//new Claim(ClaimTypes.Name,username),
new Claim(ClaimTypes.Email,email),
new Claim(ClaimTypes.Role,role),
//I need to add UserId here

:wave: @chethangowda018 is this an ASP.NET Core application?

This thread might be helpful: How to get the user identifier in an ASP.NET Core API?, Which authentication flow are you using? The access_token is issued to the user then the ClaimTypes.NameIdentifier will be the userid, if it is issued to another application you will get the clientid

1 Like