Authenticating with openid from python
I tried doing an openid login in python, and it was really easy. Here's how to do it. This uses a python openid library that ubuntu users can get as 'python-openid'.
Paste this into python (or ipython), with your openid on the second-to-last line and some working URL on the last line:
import openid.consumer.consumer import openid.store.filestore store = openid.store.filestore.FileOpenIDStore('/tmp/openid') sess = {} c = openid.consumer.consumer.Consumer(sess, store) info = c.begin('drewp.myopenid.com') info.redirectURL('http://example.com/', 'http://example.com/')
Browse to the URL you get from the last command. After possibly some confirmations on the openid server site, you'll come back to your working URL plus a long query string. Copy the query string starting right after the question mark and put it in place of the '...' in these lines. Replace example.com with your working URL again:
import cgi d = dict(cgi.parse_qsl('...')) resp = c.complete(d, 'http://example.com/')
Now resp should be a SuccessResponse object with an identity_url attribute that has been authenticated.