Python Basic Authentication source?
Fredrik Lundh
fredrik at pythonware.com
Mon May 10 03:55:38 EDT 1999
Sean Hummel <seanh at unforgettable.com> wrote:
> I am looking for code which can generate the HTTP Basic authentication
> header, from a user name and header. Anyone have any such code?
import base64, string
auth = string.strip(base64.encodestring("%s:%s" % (user, password)))
print "Authorization: Basic %s" % auth
btw, urllib can handle basic authentication for you, if you give
the URL as:
http://user:password@host/...
</F>
More information about the Python-list
mailing list