This is a simple example of using "straight" (no external libraries) Python to implement Twitter's OAuth signin. Once you've set up the .netrc file for www-data (see Makefile), make webtest might work for you, at least on Debian.
Example recipes check and check2 in Makefile are from https://dev.twitter.com/docs/auth/implementing-sign-twitter.
Some things that may not be obvious: README.htaccess is simply a symlink to the otherwise-invisible .htaccess file; and twitter_oauth.py must be symlinked to index.cgi in order to function by default. I have it disabled here so the directory contents may be viewed.
This script stores user data in $HOME/members/. If you've set www-data's home directory in /etc/apache2/, or somewhere else out of the document root, you may need to, as root:
mkdir /etc/apache2/members chown www-data.www-data /etc/apache2/members chmod 700 /etc/apache2/members
pytest is a python-fuse filesystem for testing functions in a Python script, eliminating the need to symlink the script multiple times for each function one wishes to test.