B2C Authenticate User In Web Api

Viewed 27

I have a web app where a user logs in through b2c and have certain claims set once they're logged in. Now, I also need to call an api with javascript when a user clicks a button. So that's all fine but, here's my question:

How would I get the user's claims in the api?

My api and client side web app are both in asp.net core.

Thanks in advance!

1 Answers

At first, you may refer to this document or this official sample to check if it met your requirement.

For the api, it will return user information which is signed in the app.

[HttpGet]
public IEnumerable<Todo> Get()
{
     string owner = User.Identity.Name;
     return TodoStore.Values.Where(x => x.Owner == owner);
}

Get user information from User.Identity

Related