Current user in owin authentication

后端 未结 1 1104
南方客
南方客 2020-12-24 06:18

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

相关标签:
1条回答
  • 2020-12-24 06:34

    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.

    0 讨论(0)
提交回复
热议问题