Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

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:40 Implementing the flow from scratch can be tricky, and if you make a mistake, it can leave major security holes in your app. Fortunately, the Python community has provided the oauthlib package.

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.

01:04 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 requests.

01:16 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 pyOpenSSL package.

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:05 Restart Visual Studio Code, opening the new directory as a project.

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.

02:29 If you are not using Visual Studio Code, you can activate the virtual environment by running the activate script inside of the scripts folder of the virtual environment.

02:40 Now open a new terminal window, which will trigger the activate script for the virtual environment. Create a new text file requirements.txt and add the following to it.

02:50 Each line represents one of the packages and a specific version to install. Newer versions may work, but these have been tested for the demo app.

02:59 Install the packages using pip. This will read from the requirements.txt file. Coming up next, you’ll look at some helper code.

Become a Member to join the conversation.