Mauricio Pastorini Mauricio Pastorini - 5 months ago 54
C# Question

(OWIN) How to get User from token?

Im using OWIN for Web Api, I wonder how to get the user associated to token.

enter image description here


The User associated with the transaction is a property of ApiController, which your controller inherits from. You can access it like this:

public IHttpActionResult GetUserFromToken()
    var u = User;
    return Ok(u);

If you are interested in the user's name, you can find that with User.Identity.Name.