def http_auth_request(url, host, user, passwd, user_agent=USER_AGENT):
 if DEBUG:
  httplib.HTTPConnection.debuglevel = 1
 password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
 password_manager.add_password(None, host, user, passwd)
 auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
 opener = urllib2.build_opener(auth_handler)
 urllib2.install_opener(opener)
 return http_request(url, user_agent)

def http_auth_request ( url , host , user , passwd , user_agent = USER_AGENT ) : if DEBUG : httplib . HTTPConnection . debuglevel = 1 password_manager = urllib2 . HTTPPasswordMgrWithDefaultRealm ( ) password_manager . add_password ( None , host , user , passwd ) auth_handler = urllib2 . HTTPBasicAuthHandler ( password_manager ) opener = urllib2 . build_opener ( auth_handler ) urllib2 . install_opener ( opener ) return http_request ( url , user_agent )
call an http server with authorization credentials using urllib2 .