1
00:00:05,300 --> 00:00:06,620
Welcome back everyone.

2
00:00:06,800 --> 00:00:12,020
And this series of lectures we're going to be talking about flask oath basically open authorization

3
00:00:12,020 --> 00:00:16,010
access with flask to put this into context.

4
00:00:16,010 --> 00:00:22,080
You may not always want to be the responsibility of maintaining user profiles authorisation and registration.

5
00:00:22,340 --> 00:00:27,830
Luckily there are already many popular services that can be used as potential logons such as Facebook

6
00:00:27,860 --> 00:00:28,910
or Google.

7
00:00:28,910 --> 00:00:33,170
If you've ever gone to a Web site and have been able to access the Web site by logging in through some

8
00:00:33,200 --> 00:00:37,400
other service they are using both.

9
00:00:37,420 --> 00:00:43,330
So as I mentioned popular services will use Facebook Google Twitter etc. as logging portals we can use

10
00:00:43,330 --> 00:00:51,110
the flask the library to easily add an oath open authorization Bacchantes to our application to keep

11
00:00:51,110 --> 00:00:57,620
this in context o off itself is an open standard authorization protocol or framework that describes

12
00:00:57,620 --> 00:01:03,140
how unrelated servers and services can safely allow authenticated access to their assets without actually

13
00:01:03,140 --> 00:01:06,200
sharing the initial related single log and credential.

14
00:01:06,410 --> 00:01:12,260
So if we just use basic auth such as Google log in we're not going to get full access to the person's

15
00:01:12,270 --> 00:01:13,100
Google account.

16
00:01:13,250 --> 00:01:18,290
Instead we'll at Google handle all that on their back end and just use their Google email or Google

17
00:01:18,290 --> 00:01:25,140
sign on to give access to our own Web site we're going to be working on top of an abstraction with flask

18
00:01:25,140 --> 00:01:31,050
dance and basically the way this works is that there's oh Auth. now on Version 2.0 which is that open

19
00:01:31,050 --> 00:01:33,080
authorisations standard protocol.

20
00:01:33,240 --> 00:01:38,640
Then on top of that there was a library developed called the flask dash off which helped connect flask

21
00:01:38,640 --> 00:01:41,900
applications to this oh off 2.0 framework.

22
00:01:42,060 --> 00:01:47,580
Then on top of that there was a further abstraction called the flask dance and Flast dance is the easiest

23
00:01:47,580 --> 00:01:51,450
way to use open authorization with your flask applications.

24
00:01:51,450 --> 00:01:54,740
So I'll be using the flask dance library and occasional have it.

25
00:01:54,740 --> 00:01:56,700
You can always install Flast dance.

26
00:01:56,730 --> 00:01:58,020
We'll be looking at the documentation.

27
00:01:58,020 --> 00:01:58,780
Just a second.

28
00:01:58,950 --> 00:02:03,860
But I want to make it clear that flask dance itself is not this open authorization framework.

29
00:02:03,870 --> 00:02:10,200
Instead it say layers of abstraction on top of this which allows us to easily use many services through

30
00:02:10,200 --> 00:02:14,570
kind of the same syntax protocol OK.

31
00:02:14,580 --> 00:02:19,620
So as I just mentioned the Flashdance library easily integrates a large variety of off options.

32
00:02:19,620 --> 00:02:24,190
And more importantly has detailed QuickStart guides allowing you to easily implement any of these.

33
00:02:24,190 --> 00:02:30,450
Olof Bacchantes into your web application let's go ahead and head to the documentation to follow along

34
00:02:30,450 --> 00:02:32,390
with the guide for the Google QuickStart.

35
00:02:32,530 --> 00:02:34,470
Go to flask dasht dance.

36
00:02:34,510 --> 00:02:35,280
Read the docs.

37
00:02:35,320 --> 00:02:40,440
I know so we can explore documentation just a little bit before we actually head on to coding this out

38
00:02:40,690 --> 00:02:41,780
in the next lecture.

39
00:02:41,950 --> 00:02:43,090
I'm going to jump to this.

40
00:02:43,090 --> 00:02:44,680
You are all in my browser now.

41
00:02:44,680 --> 00:02:44,940
All right.

42
00:02:44,950 --> 00:02:46,550
Here I am at flask dance.

43
00:02:46,570 --> 00:02:51,370
And the reason is called Dance because it kind of does a dance with the open authorization to kind of

44
00:02:51,370 --> 00:02:53,010
connect everything together.

45
00:02:53,080 --> 00:02:56,920
What's really important here are kind of two parts installation and quick starts.

46
00:02:56,950 --> 00:02:58,380
So installation is quite simple.

47
00:02:58,390 --> 00:03:02,200
It should already be in the requirements text but in case you don't have it yet you can do Pipp install

48
00:03:02,200 --> 00:03:03,070
Flast dance.

49
00:03:03,280 --> 00:03:08,260
And if you intend to use the sequel alchemy a back end as a little extra you can say Flast that's sequel

50
00:03:08,260 --> 00:03:08,910
alchemy.

51
00:03:08,950 --> 00:03:13,690
We'll talk about this later on but right now all you need to do is say Pipp style flask dance at your

52
00:03:13,690 --> 00:03:14,710
command line.

53
00:03:14,710 --> 00:03:18,480
Now we go back to the documentation overview lodestar is quick starts here.

54
00:03:18,580 --> 00:03:23,320
And this basically shows you the QuickStart for all the open authorization portals that we can use a

55
00:03:23,320 --> 00:03:24,270
flask dance.

56
00:03:24,340 --> 00:03:29,800
There are the major ones like Google Twitter but there's also other ones like Dropbox slack and so on.

57
00:03:29,950 --> 00:03:32,410
And you can see here more details on the providers.

58
00:03:32,410 --> 00:03:37,110
Keep in mind these API may change often so you'll always want to reference documentation.

59
00:03:37,230 --> 00:03:42,940
And in case you have any issues maybe reference the hub issues page for Flast dance we're going to start

60
00:03:42,940 --> 00:03:44,950
off by playing around Google QuickStart.

61
00:03:45,130 --> 00:03:48,760
So all I have to do is if you're ever interested in using one of these just click on the QuickStart

62
00:03:48,880 --> 00:03:53,590
such as Google search and it will tell you how to set up the application basically how to set up your

63
00:03:53,590 --> 00:03:58,920
client API keys so that Google knows you're giving permission to your flask application.

64
00:03:58,920 --> 00:04:01,920
So in order to do that we'll have to have a Google account.

65
00:04:01,930 --> 00:04:07,120
So basically you follow the instructions here that set up the client key the secret key and then the

66
00:04:07,120 --> 00:04:09,330
authorized redirect you are.

67
00:04:09,700 --> 00:04:14,320
Once you've done that you can essentially just copy and paste this code right here in order to have

68
00:04:14,320 --> 00:04:15,770
the very basic setup.

69
00:04:15,820 --> 00:04:20,060
Here we can see that we created a flask application you set up a blueprint.

70
00:04:20,080 --> 00:04:25,670
This one is the Google blueprint and you provide a client id and a client secret code which describes

71
00:04:25,750 --> 00:04:29,340
how to set up here and then you register that blueprint.

72
00:04:29,410 --> 00:04:33,730
And here they show you a very basic example that if you're not authorized you redirect for the Google

73
00:04:33,730 --> 00:04:34,450
logon.

74
00:04:34,630 --> 00:04:38,980
If you are authorized However they go ahead and grab your user information and then they'll just return

75
00:04:38,980 --> 00:04:39,560
back.

76
00:04:39,580 --> 00:04:41,610
In this case you return back your e-mail.

77
00:04:41,620 --> 00:04:45,520
So let's go in and check out one other examples we can really get an understanding of the QuickStart

78
00:04:45,530 --> 00:04:49,110
because it's basically what you do when you come to the Flast dance documentation.

79
00:04:49,120 --> 00:04:52,330
So let's imagine I wanted to use slack as my logon.

80
00:04:52,330 --> 00:04:53,750
So I click on slacke QuickStart.

81
00:04:54,050 --> 00:04:58,870
They'll say set up the application see basically visit this Web site register an application was slack

82
00:04:59,050 --> 00:05:00,420
and then set the read there.

83
00:05:00,460 --> 00:05:06,850
You are I to this localhost log slack authorize the take now of the client id and the client secret.

84
00:05:06,850 --> 00:05:10,810
And then it's essentially the same syntax you just flipping out of cup or switching out a couple of

85
00:05:10,810 --> 00:05:11,390
things.

86
00:05:11,590 --> 00:05:17,020
They say make slack blueprint that you're importing here from stance and you can see here that basically

87
00:05:17,020 --> 00:05:21,710
the response what you're grabbing is slightly different but the actual flow is very similar.

88
00:05:21,850 --> 00:05:26,840
You set up your blueprint and then you're grabbing information and redirect him to slack log in in case

89
00:05:26,840 --> 00:05:28,010
you're not logged in yet.

90
00:05:28,300 --> 00:05:28,800
OK.

91
00:05:28,930 --> 00:05:34,420
So that being said let's go ahead and work off of the quick sort example we'll be using the Google example.

92
00:05:34,600 --> 00:05:38,230
And we're going to add in some templates so it's a little more complex than what you see here the QuickStart

93
00:05:38,470 --> 00:05:41,260
but I'm going to follow along very closely to that flow.

94
00:05:41,260 --> 00:05:42,940
All right we'll see you in the next lecture.
