Current user in owin authentication

On method GrantResourceOwnerCredentials once you add claims after validating the username password you need to add this claim:

identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));

By doing this the UserId will be filled when you call User.Identity.Name inside protected controller.
Hope this solves your issue.

Leave a Comment