Setting Up Your Development Environment
00:00 To build the demo app you’ll make use of several Python packages. Flask is a microframework for building web apps. Being a microframework, Flask provides only the bare minimum services needed to create a web app. Basically, this just means handling HTTP traffic and mapping requests to routes.
00:19 Flask-Login is a package that provides user session management. In other words, it simply determines if a user is logged in or logged out. It also does some other things, but remember that a large part of authenticating users in the demo app will be handled by Google. As you saw earlier, there are a number of steps in the OAuth flow.
00:52 This package is widely used and has almost a decade of experience, so you can be sure that it is sufficient for your needs. You’ll also need a way to call the URLs on the provider, independent of Flask.
This will be required to exchange the authorization code for the tokens. While the Python standard library includes the
urllib package, here’s an easier way to make HTTP requests—and it’s a package called
The author refers to it as “HTTP for Humans,” and it reduces calling an HTTP endpoint to just a few lines of code. Finally, you may have noticed that the URLs provided to Google during the registration process use secure HTTP, and this is a requirement. By default, Flask does not implement secure HTTP but instead relies on the
01:41 It’s time to get hands-on. I’ll be using Visual Studio Code with the Python extension installed for the demo, but you can use any text editor such as Atom or IDE such as PyCharm. In Visual Studio Code, open the terminal with Control + ` (backtick) and create a new directory to serve as the project root. Next, create a virtual environment for the demo app.
02:11 In Visual Studio Code, associate the project with the virtual environment. Press Control + Shift + P, or Command + Shift + P on macOS, and search for “python select default interpreter.” Select that command, and then the virtual environment you just created.
Become a Member to join the conversation.