In this section, we are going to create the program that will perform authentication for us so we can use the Twitter API. We are going to do that using a simple Flask application that will expose two routes. The first is the root /, which will just load and render a simple HTML template with a button that will redirect us to the Twitter authentication dialog.
The second route that we are going to create is /callback. Remember when we specified the callback URL in the Twitter app configuration? This is the route that will be called after we authorize the app. It will return an authorization token that will be used to perform requests to the Twitter API. So let's get right into it!
Before we start implementing the Flask app, we need to add another model to our model's module. This model will represent the request authorization data. Open...