I started to build a web api for mobile apps and I\'m having a hard time with implementing authentication. I use Bearer and although everything is supposed to be fine, I can
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.