From: fredrik at pythonware.com (Fredrik Lundh)
Date: Mon, 10 May 1999 07:55:38 GMT
Subject: Python Basic Authentication source?
References: <tudZ2.1338$2w4.79013@news.uswest.net>
Message-ID: <009501be9aba$7ffaa5c0$f29b12c2@pythonware.com>
X-UID: 1902                                                 

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 at host/...

</F>





