Wonderful.
And once we have the art middleware in place now.
Well, now we need to understand how we can send that token.
So how we can send a token from the front end as well as the postman.
And let's start with the postman and ask some resource for that.
One is a site by the name of JWT i o and the site name is JWT Io.
And more specifically, you're looking for the introduction.
I'm here.
You can find a bunch of useful info about JWT or the address on web tokens.
Now, I'm not going to read all of them, but I did decide to pretty much just showcase the resource.
Otherwise it comes out that I'm just going to be repeating whatever they say over here.
So go to introduction, yada yada yada.
Keep scrolling and you're looking for this.
How do JSON tokens work?
That's an awesome question.
Now, more specifically, we want to go with this whenever the user wants to access a protected root
or resource.
The user agent, so think postman or front man should send Jan 20 typically in the authorization letter
using the bearer schema.
How is that going to look like like this?
Just like I showcased in our complete project authorization, Burr.
And what do you know we have here a token?
Now, let's not worry about this right now.
We'll do that later in the video.
For now, what we want to do is go to a postman and test it out, whether we can actually do it and
right from the get go.
I want to tell you that, yes, in this video, we'll do it manually.
Essentially, we'll have to add to one of our routes.
Keep in mind, all the jobs will be restricted, as well as the update users.
So in my case, I'm going to go with update user, but Rentschler will have to add to all of them,
but we're not going to do that manually.
So next VIDEO I'll show you how we can basically speed this up at the moment.
We go with the register or log in.
And as a very, very, very quick side note, this is actually where I do prefer cookies instead of
just sending it back JWT in response because with cookies, everything's taken care of again, just
a minor signal.
So I want to go to update user first.
We're not going to be sending anything as far as the body yet, but we do want to go to a headers.
Again, we're not looking for a body.
We are looking for headers.
And here what was the hero name?
Well, if I remember correctly, we need to go with authorization.
Correct.
So we get this sucker over here.
So we go with authorization.
And then as far as the value, well, remember this needs to be 280.
So we go with Barbara event space and then we need to pass in the token.
So let me log in one more time.
John, you can grab it here.
This is my token.
We want a copy.
And then let's go back to update user again to make sure there's a space.
And then copy and paste.
Now, before we do anything as far as sending the request, now let's go back to JWT and order.
So we're here and we have this.
This can be, in certain cases, Hezbollah.
The servers protected or will check for a valid JWT in your authorization header.
And if it's present, then we allow the resources and blah blah blah.
So again, this is just pretty much details.
What are we doing if it's present and if it's not?
And this is something we will cover so we don't need to worry about that.
The main idea that I want you to take away from this one where it's going to be located.
So I noticed this sample code we have here on Earth, Jess.
And first, I'm looking forward to Hatter's, so I'm going to go and harass.
That's where it's going to be.
And the second one I want to showcase is the author.
So I want to go off and add these two things.
I just want to console.log because I want you to see, where are they going to be located?
So let me navigate you off, Jess.
And again, it's going to be in the Iraq, correct?
So in my case, I'm going to go with hirers and then nine one is equal to Rick and headers.
That's the first one.
Then let's copy and paste.
I think it's going to be faster and I'm going to be looking for authorization.
So and then let's also call this authorization, however, so essentially with a second one, we're
just speeding this up.
But I do want to showcase that, yes, there is a harassed property and in there we'll see all the haters,
but more specifically will be looking for this one.
And what are we want to do now?
Now we want to copy and paste and essentially set up the headers.
In the console.log and in the second case of terror.
So let's say this one.
I'll leave this one open, meaning the council and now let's take a look what happens when we send a
request from the postman?
So let me first save this one and then let's send it again.
The response is going to be update user.
I mean, that is already expected.
What is more interesting is this If we go back to our council, what do you see over there?
I see authorization when I see the banner and then I see the token current good.
And then if we just log the AF header, yeah, we have better and we have the value.
So now we have the setup in place where we'll be sending it back from the front.
And again, yes, from the front, and we'll have to implement some code.
It's not just going to magically go from postman to the front then, but the idea is going to be exactly
the same where we will grab this from our state and then we'll set up a request that will go to our
server and on a server in the following readers we will check for authorization header if it's present,
if the token is still out.
Awesome.
You can access, modify whatever you want to do with the resources.
If not, we'll throw the authentication error.