The full code for this sample is available at https://github.com/jcleblanc/programming-social-applications/tree/master/chapter_12/hybrid-python.
Now that we’ve looked at a hybrid OpenID OAuth implementation in PHP, let’s explore a similar implementation using Python.
In this example, we’ll take the OpenID example that we explored in Chapter 11 and modify it by introducing a request to fetch a preapproved request token when having the user authorize the application. We will then exchange this preapproved request token for an OAuth access token, which will allow us to make requests on the user’s behalf.
We’ll start this process by identifying the library dependencies we need to build out this project. Then we’ll proceed by jumping into the YAML file that we will use to load the example on Google App Engine, which will run our program.
If you are running this Yahoo! example in App Engine on localhost, you should be aware that if you create an application on Yahoo! (and numerous other services) to obtain the necessary OAuth keys, you may be required to verify your domain. This verification will fail on localhost and may prevent you from completing your application. You should deploy applications running within App Engine prior to executing so that your production environment can be verified.
Before we begin this project, we need to define the libraries that we’ll use to complete the OAuth OpenID hybrid auth process.