Implementing OpenID Using Python

We’ve explored the OpenID implementation using PHP as the backing server-side language, so now let’s see what shape the implementation takes when Python is used as the main delivery language. We will cover the same type of implementation as before—one that gives us a program that can perform discovery on a number of different OpenID providers and allow the user to sign in using their services. We will also integrate our same three OpenID extensions to provide additional security and user information during the process:

  • Simple Registration for basic user information

  • Attribute Exchange for more extensive user information

  • PAPE for additional security levels

At the end of the example, we will have a complete end-to-end program that allows users to log in using a range of OpenID providers.

Getting the required OpenID library

For this example, we are using the Janrain OpenID Python library, which you can find in Janrain’s list of libraries at Before we begin implementing the code for this example, we first need to install the OpenID library.


Before running the python install command to install the OpenID library, you will need to have the distutils module installed. This is part of the Python standard library, but some distributions package it separately in a “python-dev” ...

Get Programming Social Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.