How to set Claims from ASP.Net OpenID Connect OWIN components? How to set Claims from ASP.Net OpenID Connect OWIN components? asp.net asp.net

How to set Claims from ASP.Net OpenID Connect OWIN components?


Is there a specific reason for which you are adding a new ClaimsIdentity?

The simplest way of doing what you are aiming at is to retrieve the ClaimsIdentity that was generated by validating the incoming token, via ClaimsIdentity claimsId = context.AuthenticationTicket.Identity; once you have it, just add claims to it. The rest of the middleware will take care of serializing it in the session cookie along with everything else, place the result in the current ClaimsPrincipal, and all those other things you appear to be trying to do manually.
HTH
V.