1
00:00:02,590 --> 00:00:03,830
Hi, welcome back!

2
00:00:03,830 --> 00:00:05,590
In this video we are going to

3
00:00:05,590 --> 00:00:08,980
test our login with Postman, and there are a couple of

4
00:00:08,980 --> 00:00:11,640
changes we have to make in order to get it to work.

5
00:00:11,640 --> 00:00:12,840
So, let's get to it.

6
00:00:12,840 --> 00:00:15,130
Make sure your app is running,

7
00:00:15,130 --> 00:00:18,510
and then we can go ahead and register a user.

8
00:00:18,510 --> 00:00:20,143
So I'm gonna send a request here,

9
00:00:20,143 --> 00:00:23,250
and I'm just creating a user, but it already exists,

10
00:00:23,250 --> 00:00:27,550
because datalog db in my case hasn't been deleted.

11
00:00:27,550 --> 00:00:30,053
So, you can that a user with a username already exists.

12
00:00:30,053 --> 00:00:32,895
Then you can go over to your auth endpoint,

13
00:00:32,895 --> 00:00:37,447
but you'll see if you send this it'll say 404.

14
00:00:38,920 --> 00:00:40,000
Why 404?

15
00:00:40,000 --> 00:00:43,810
Well, the slash auth endpoint no longer exists.

16
00:00:43,810 --> 00:00:47,640
Now we have to use slash login, because that's

17
00:00:47,640 --> 00:00:49,570
the new resource we've created.

18
00:00:49,570 --> 00:00:52,040
So we can send this away, and now we get

19
00:00:52,040 --> 00:00:54,683
an access token and a refresh token.

20
00:00:56,240 --> 00:00:58,667
This is exactly what we told our resource to return.

21
00:00:58,667 --> 00:01:01,560
So, there's no magic going on in here.

22
00:01:01,560 --> 00:01:02,620
There're just two things.

23
00:01:02,620 --> 00:01:04,410
The refresh token is gonna be useful in a

24
00:01:04,410 --> 00:01:06,380
few videos times, so don't worry about it.

25
00:01:06,380 --> 00:01:09,063
And the access token is just our JWT.

26
00:01:10,870 --> 00:01:12,373
I'm just gonna change the name of this

27
00:01:12,373 --> 00:01:15,613
auth endpoint, just to be safe there.

28
00:01:16,450 --> 00:01:18,460
And now we have our access token.

29
00:01:18,460 --> 00:01:20,806
Our tests are going to save this access token

30
00:01:20,806 --> 00:01:23,490
into our collection.

31
00:01:23,490 --> 00:01:25,420
Sorry, our environment.

32
00:01:25,420 --> 00:01:28,920
So, we can go into GET item

33
00:01:29,980 --> 00:01:33,853
that has this authorization header and send the request.

34
00:01:36,020 --> 00:01:38,960
See, but then you get a message saying

35
00:01:38,960 --> 00:01:41,160
bad authorization header.

36
00:01:41,160 --> 00:01:45,199
Expected value bearer JWT.

37
00:01:45,199 --> 00:01:49,390
So, instead of JWT and then the JWT,

38
00:01:49,390 --> 00:01:54,030
it expects to have bearer, and then the JWT.

39
00:01:54,030 --> 00:01:55,370
So, just like that, remember to have

40
00:01:55,370 --> 00:02:00,370
bearer space the JWT at the end, and there you have it.

41
00:02:01,110 --> 00:02:04,560
Okay, so that's the only changes you need to make in Postman

42
00:02:04,560 --> 00:02:06,160
in order to get all this to work.

43
00:02:06,160 --> 00:02:10,780
Whenever you're using Flask JWT Extended, use bearer.

44
00:02:10,780 --> 00:02:13,100
And there are ways to configure this so it's not bearer,

45
00:02:13,100 --> 00:02:14,576
so it's something else if you want.

46
00:02:14,576 --> 00:02:16,717
But those will be available in the official

47
00:02:16,717 --> 00:02:19,690
documentation for Flask JWT Extended.

48
00:02:19,690 --> 00:02:21,820
I'm not gonna go into too much detail in this course

49
00:02:21,820 --> 00:02:24,820
about how to configure all of these different things.

50
00:02:24,820 --> 00:02:27,480
We will, however, later on in the course,

51
00:02:27,480 --> 00:02:28,892
just for your information,

52
00:02:28,892 --> 00:02:33,450
look at how to make these messages a little bit nicer.

53
00:02:33,450 --> 00:02:37,260
Instead of msg and something here, we're gonna

54
00:02:37,260 --> 00:02:39,620
have a nicer message with some suggestions

55
00:02:39,620 --> 00:02:41,939
of what you can do, and so forth.

56
00:02:41,939 --> 00:02:44,020
Just gonna line them out a bit nicer.

57
00:02:44,020 --> 00:02:49,020
Also, so you learn how to modify this on your own projects.

58
00:02:50,351 --> 00:02:51,810
So, that's it for this video.

59
00:02:51,810 --> 00:02:54,290
Just wanted to double check that everything's working

60
00:02:54,290 --> 00:02:56,700
and show you the small changes you have to make.

61
00:02:56,700 --> 00:02:58,150
I'll see you on the next one.

