From the course: Building and Securing Restful APIs in .NET

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Enabling ASP.NET Identity for APIs

Enabling ASP.NET Identity for APIs - .NET Tutorial

From the course: Building and Securing Restful APIs in .NET

Enabling ASP.NET Identity for APIs

- [Instructor] We're going to look at another option, a little richer than our API Key Example for authenticating users. And we're going to use the built-in Identity Model within ASP.NET Core built on Entity Framework. So to start, we're going to do our dotnet add package, as we've got some additional packages we need to add. So it's going to be Microsoft.aspnetcore.identity.entityframeworkcore. And that's going to give us everything we need to leverage our database as our store for our user information and give us the ability to authenticate users. You can also add Manage Roles in there as well. It's all built on the ASP.NET Identity Model. So there's lots of documentation around that. We're going to go back, way back to our database context that we haven't worked on for a while. So we're going to go from the generic DbContext to this Identity, spell it right, IdentityDbContext of IdentityUser. We've got a couple of name spaces that got added up there for us from…

Contents