From the course: Advanced Web APIs with ASP.NET Core in .NET 6
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Adding token-based authentication - C# Tutorial
From the course: Advanced Web APIs with ASP.NET Core in .NET 6
Adding token-based authentication
- In order to add token based authentication to our API we need to do some extra steps and I've decided that I will implement everything and show you the result. That's probably a bit more efficient than you watching me type for an extended amount of time. Everything takes place in the existing web application; pages based web application to be precise. And the first thing I did was I went to the program CS file and added support for controllers because I would like to add a controller and that controller will both serve as an endpoint to generate a token. And also as an API endpoint, that will then be protected. And that call to 'build.services.addcontrollers' will be complemented by 'app.mapcontrollers'. Right? So now the application supports ABC and APIs as well. I then created a controllers folder and in that I set up a new API controller called Token Controller. And you see from a number of usings here at the top that there…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Introduction31s
-
(Locked)
Enforcing HTTPS5m 16s
-
(Locked)
Consuming the API with JavaScript4m 44s
-
(Locked)
Cross-origin resource sharing (CORS)4m 12s
-
(Locked)
Enabling CORS4m 44s
-
(Locked)
Adding ASP.NET Core Identity6m 56s
-
(Locked)
Adding token-based authentication8m 51s
-
(Locked)
OAuth and OpenID Connect4m 19s
-
(Locked)
Securing the API with IdentityServer6m 10s
-
(Locked)
Consuming the protected API6m 40s
-
(Locked)
-