1
00:00:00,180 --> 00:00:00,630
Wonderful.

2
00:00:00,900 --> 00:00:03,600
And once we have the art middleware in place now.

3
00:00:04,200 --> 00:00:07,920
Well, now we need to understand how we can send that token.

4
00:00:08,670 --> 00:00:12,330
So how we can send a token from the front end as well as the postman.

5
00:00:12,360 --> 00:00:15,870
And let's start with the postman and ask some resource for that.

6
00:00:15,870 --> 00:00:22,140
One is a site by the name of JWT i o and the site name is JWT Io.

7
00:00:22,380 --> 00:00:24,660
And more specifically, you're looking for the introduction.

8
00:00:24,780 --> 00:00:25,200
I'm here.

9
00:00:25,200 --> 00:00:30,270
You can find a bunch of useful info about JWT or the address on web tokens.

10
00:00:30,510 --> 00:00:36,930
Now, I'm not going to read all of them, but I did decide to pretty much just showcase the resource.

11
00:00:36,930 --> 00:00:41,520
Otherwise it comes out that I'm just going to be repeating whatever they say over here.

12
00:00:41,790 --> 00:00:43,930
So go to introduction, yada yada yada.

13
00:00:43,950 --> 00:00:46,190
Keep scrolling and you're looking for this.

14
00:00:46,530 --> 00:00:48,570
How do JSON tokens work?

15
00:00:48,900 --> 00:00:50,460
That's an awesome question.

16
00:00:50,850 --> 00:00:58,140
Now, more specifically, we want to go with this whenever the user wants to access a protected root

17
00:00:58,170 --> 00:00:58,890
or resource.

18
00:00:59,930 --> 00:01:09,170
The user agent, so think postman or front man should send Jan 20 typically in the authorization letter

19
00:01:09,590 --> 00:01:11,690
using the bearer schema.

20
00:01:12,200 --> 00:01:14,450
How is that going to look like like this?

21
00:01:15,020 --> 00:01:19,640
Just like I showcased in our complete project authorization, Burr.

22
00:01:19,970 --> 00:01:23,060
And what do you know we have here a token?

23
00:01:23,510 --> 00:01:25,940
Now, let's not worry about this right now.

24
00:01:26,210 --> 00:01:28,790
We'll do that later in the video.

25
00:01:28,910 --> 00:01:35,330
For now, what we want to do is go to a postman and test it out, whether we can actually do it and

26
00:01:35,330 --> 00:01:36,310
right from the get go.

27
00:01:36,320 --> 00:01:39,710
I want to tell you that, yes, in this video, we'll do it manually.

28
00:01:39,950 --> 00:01:42,980
Essentially, we'll have to add to one of our routes.

29
00:01:43,310 --> 00:01:47,510
Keep in mind, all the jobs will be restricted, as well as the update users.

30
00:01:47,510 --> 00:01:51,830
So in my case, I'm going to go with update user, but Rentschler will have to add to all of them,

31
00:01:52,220 --> 00:01:53,810
but we're not going to do that manually.

32
00:01:53,820 --> 00:01:59,000
So next VIDEO I'll show you how we can basically speed this up at the moment.

33
00:01:59,000 --> 00:02:01,030
We go with the register or log in.

34
00:02:01,040 --> 00:02:06,380
And as a very, very, very quick side note, this is actually where I do prefer cookies instead of

35
00:02:06,380 --> 00:02:12,740
just sending it back JWT in response because with cookies, everything's taken care of again, just

36
00:02:12,740 --> 00:02:14,180
a minor signal.

37
00:02:14,510 --> 00:02:17,090
So I want to go to update user first.

38
00:02:17,330 --> 00:02:22,480
We're not going to be sending anything as far as the body yet, but we do want to go to a headers.

39
00:02:23,180 --> 00:02:24,530
Again, we're not looking for a body.

40
00:02:24,890 --> 00:02:26,240
We are looking for headers.

41
00:02:26,630 --> 00:02:28,760
And here what was the hero name?

42
00:02:29,690 --> 00:02:33,870
Well, if I remember correctly, we need to go with authorization.

43
00:02:34,190 --> 00:02:34,580
Correct.

44
00:02:34,940 --> 00:02:37,220
So we get this sucker over here.

45
00:02:37,370 --> 00:02:39,820
So we go with authorization.

46
00:02:40,400 --> 00:02:45,140
And then as far as the value, well, remember this needs to be 280.

47
00:02:45,530 --> 00:02:50,930
So we go with Barbara event space and then we need to pass in the token.

48
00:02:51,230 --> 00:02:52,700
So let me log in one more time.

49
00:02:52,770 --> 00:02:54,530
John, you can grab it here.

50
00:02:54,940 --> 00:02:55,940
This is my token.

51
00:02:56,390 --> 00:02:57,350
We want a copy.

52
00:02:57,770 --> 00:03:02,570
And then let's go back to update user again to make sure there's a space.

53
00:03:03,060 --> 00:03:04,430
And then copy and paste.

54
00:03:04,850 --> 00:03:12,200
Now, before we do anything as far as sending the request, now let's go back to JWT and order.

55
00:03:12,200 --> 00:03:13,180
So we're here and we have this.

56
00:03:13,440 --> 00:03:15,430
This can be, in certain cases, Hezbollah.

57
00:03:15,800 --> 00:03:24,380
The servers protected or will check for a valid JWT in your authorization header.

58
00:03:24,860 --> 00:03:29,270
And if it's present, then we allow the resources and blah blah blah.

59
00:03:29,360 --> 00:03:32,330
So again, this is just pretty much details.

60
00:03:32,720 --> 00:03:35,660
What are we doing if it's present and if it's not?

61
00:03:35,810 --> 00:03:39,080
And this is something we will cover so we don't need to worry about that.

62
00:03:39,350 --> 00:03:43,550
The main idea that I want you to take away from this one where it's going to be located.

63
00:03:44,270 --> 00:03:47,660
So I noticed this sample code we have here on Earth, Jess.

64
00:03:48,050 --> 00:03:51,560
And first, I'm looking forward to Hatter's, so I'm going to go and harass.

65
00:03:51,860 --> 00:03:52,880
That's where it's going to be.

66
00:03:53,180 --> 00:03:55,700
And the second one I want to showcase is the author.

67
00:03:56,270 --> 00:03:59,330
So I want to go off and add these two things.

68
00:03:59,660 --> 00:04:04,610
I just want to console.log because I want you to see, where are they going to be located?

69
00:04:05,060 --> 00:04:07,480
So let me navigate you off, Jess.

70
00:04:08,030 --> 00:04:10,580
And again, it's going to be in the Iraq, correct?

71
00:04:10,940 --> 00:04:16,579
So in my case, I'm going to go with hirers and then nine one is equal to Rick and headers.

72
00:04:17,029 --> 00:04:17,839
That's the first one.

73
00:04:18,110 --> 00:04:19,220
Then let's copy and paste.

74
00:04:19,220 --> 00:04:23,690
I think it's going to be faster and I'm going to be looking for authorization.

75
00:04:24,820 --> 00:04:30,700
So and then let's also call this authorization, however, so essentially with a second one, we're

76
00:04:30,700 --> 00:04:31,600
just speeding this up.

77
00:04:31,870 --> 00:04:36,880
But I do want to showcase that, yes, there is a harassed property and in there we'll see all the haters,

78
00:04:36,880 --> 00:04:39,400
but more specifically will be looking for this one.

79
00:04:39,730 --> 00:04:40,870
And what are we want to do now?

80
00:04:41,200 --> 00:04:45,460
Now we want to copy and paste and essentially set up the headers.

81
00:04:46,470 --> 00:04:50,540
In the console.log and in the second case of terror.

82
00:04:51,360 --> 00:04:52,560
So let's say this one.

83
00:04:52,950 --> 00:04:58,830
I'll leave this one open, meaning the council and now let's take a look what happens when we send a

84
00:04:58,840 --> 00:05:00,630
request from the postman?

85
00:05:00,840 --> 00:05:04,500
So let me first save this one and then let's send it again.

86
00:05:04,830 --> 00:05:06,420
The response is going to be update user.

87
00:05:06,540 --> 00:05:09,480
I mean, that is already expected.

88
00:05:09,900 --> 00:05:14,580
What is more interesting is this If we go back to our council, what do you see over there?

89
00:05:14,940 --> 00:05:20,220
I see authorization when I see the banner and then I see the token current good.

90
00:05:20,520 --> 00:05:25,920
And then if we just log the AF header, yeah, we have better and we have the value.

91
00:05:26,490 --> 00:05:31,440
So now we have the setup in place where we'll be sending it back from the front.

92
00:05:31,440 --> 00:05:34,680
And again, yes, from the front, and we'll have to implement some code.

93
00:05:34,920 --> 00:05:39,150
It's not just going to magically go from postman to the front then, but the idea is going to be exactly

94
00:05:39,150 --> 00:05:46,890
the same where we will grab this from our state and then we'll set up a request that will go to our

95
00:05:46,890 --> 00:05:53,880
server and on a server in the following readers we will check for authorization header if it's present,

96
00:05:54,210 --> 00:05:55,920
if the token is still out.

97
00:05:56,130 --> 00:05:56,610
Awesome.

98
00:05:56,940 --> 00:06:00,780
You can access, modify whatever you want to do with the resources.

99
00:06:01,050 --> 00:06:03,990
If not, we'll throw the authentication error.

