HTTP Authentication

Lakshman scorpion032 at gmail.com
Mon Apr 6 06:07:30 EDT 2009


Whats is the python urllib2 equivallent of

curl -u username:password status="abcd" http://example.com/update.json

I did this:

handle = urllib2.Request(url)
authheader =  "Basic %s" % base64.encodestring('%s:%s' % (username,
password))
handle.add_header("Authorization", authheader)

Is there a better / simpler way?



More information about the Python-list mailing list