From the course: Building Angular and ASP.NET Web API Apps
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Generating a token
From the course: Building Angular and ASP.NET Web API Apps
Generating a token
- [Narrator] Before we start implementing the Token generation, it is important to know what a Token is. And a Token is a piece of data which is created by a server, in our case, the Web API, and this piece of data contains enough data to identify a user. So, let us create a method which we are going to use to generate Tokens when we want to sign in or create a user. So for that, let us go to our Web API project. In the authentication controller, after the register method, let us write in here, private object, and then CreateToken. This method is going to take as a parameter via user. So user and then user. Now we don't want to just return a general object, we want to return a JWT Package and this package is going to contain our Token string, and the Username. So for that let us write in here, JwtPackage. Now, since this does not exist, let us create it in our line 37, for that write, public class JwtPackage. And this class will have two properties. The first property is going to be…
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)
Setting up AuthController5m 10s
-
(Locked)
Setting up AuthService3m 8s
-
(Locked)
Creating a register component5m 6s
-
(Locked)
Registering users6m 18s
-
(Locked)
Generating a token6m 53s
-
(Locked)
Requesting a token from Angular4m 42s
-
(Locked)
Authentication check via tokens5m 11s
-
(Locked)
Logging out users1m 54s
-
(Locked)
Creating an Angular login component4m 47s
-
(Locked)
Getting data from the login form4m 25s
-
(Locked)
Logging in users4m 20s
-
(Locked)
Handling errors in angular4m 2s
-
(Locked)
-
-