Am sending Bearer Token in the header from Postman. Now I need to get User Claim in the API using that bearer token. The code which I tried is not working means am not getting user Name/Email. How can I get user claim using Bearer Token?
public class RepositoryUserAccount : IRepositoryUserAccount
{
private readonly HttpContext _httpContext;
public RepositoryUserAccount(IHttpContextAccessor httpContextAccessor)
{
this._httpContext = httpContextAccessor.HttpContext;
}
public async Task EnableAuthenticator()
{
ClaimsPrincipal currentUser = _httpContext.User;
var currentUserName = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;
}
}