From the course: React: Authentication
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Generating JSON Web Tokens - React.js Tutorial
From the course: React: Authentication
Generating JSON Web Tokens
- [Narrator] All right, so now that we've created our signup route on our server, we need to actually add jsonwebtokens into this. Now, there are a lot of different packages that you can use for doing this, but the one that we're going to use is the most straightforward, and that is jsonwebtoken. So just like we did with the other packages, we're going to need to install this one. So you can actually just open up, well here, we'll open up the same one that we had. We're going to say npm install jsonwebtoken, all one word, no dashes, nothing. And that will install that for us. So now that we've done that, here's how we add this to our signup route. First of all, we'll just add this in as an import. We'll say const jwt = require jsonwebtoken. All right, now that we've done that, let's actually scroll down to where we're going to need to generate that token. So, this is going to be after we've inserted the user into the database, right? So, we've already added the user to the database…
Contents
-
-
-
What is user authentication?6m 48s
-
Basic project setup3m 20s
-
(Locked)
Creating private React routes8m 17s
-
(Locked)
JSON Web Token basics11m 29s
-
(Locked)
Solution: Working with JSON Web Tokens2m 43s
-
(Locked)
Adding a sign-up route to the server12m 20s
-
(Locked)
Generating JSON Web Tokens6m 9s
-
(Locked)
Adding a log-in route to the server4m 32s
-
(Locked)
Adding JWTs to the front-end4m 19s
-
(Locked)
Parsing JWT data4m 29s
-
(Locked)
Adding JWTs to sign-up and log-in pages5m 37s
-
(Locked)
Adding JWTs to the user info page9m 54s
-
(Locked)
Adding an "update user" route11m 47s
-
(Locked)
Adding update functionality to the front-end4m 49s
-
(Locked)
State management for tokens7m 18s
-
(Locked)
Adding log-out functionality3m 47s
-
-
-
-
-
-
-
-