Jeeten Parmar
Jeeten Parmar

Reputation: 5757

Get email address from OAuth token Asp.net MVC

I am using OAuth security in my Asp.net MVC Web API. I am adding an email address and password in ClaimsIdentity to generate the token. It is working fine as expected.

Now, to get that user data, I want to convert token to email address and get data based on it. Is it possible to do it?

Upvotes: 0

Views: 249

Answers (1)

Kahbazi
Kahbazi

Reputation: 14995

You can use this code in your action

public class TestController : ApiController
{
    public void Test()
    {
        string email = ((ClaimsIdentity)User.Identity).FindFirst(<EMAIL_CLAIM_TYPE>).Value;
    }
}

Upvotes: 1

Related Questions