[twill] Question about HTTP basic authentication handling

subscriptions at smart-knowhow.de subscriptions at smart-knowhow.de
Fri Mar 2 04:44:17 PST 2007


(Sorry, forgot the heading)

Hi folks, 

I'm new to twill and - first of all - happy to have found it. I had such a project in mind for a long time and I'm glad to find it already realized. 

I'm currently trying out the capabilities. I'm currently working in a restricted corporate environment with lots of proxys and authentications. 

I already found out how to deal with the authentication-requiring proxys and I'm currently dealing with the login to a restricted web site. 

I'm currently not able to log in with twill into a site, while I can access the site via urllib2 with the following script: 

import urllib2 
passmgr = urllib2.HTTPBasicAuthHandler() 
passmgr.add_password("LDAP Intranet-Login:", 'webportal', 'myname', 'mypw') 

opener = urllib2.build_opener(passmgr) 
urllib2.install_opener(opener) 

f = urllib2.urlopen('http://webportal/twiki/bin/view/Main/WebHome') 
buf = f.read() 
print buf 
f.close() 

If I use the same credentials within a "add_auth" command in twill it won't work (I get a 403 access forbidden). 

What I was wondering about is: twill uses HTTPPasswordMgr where my script uses HTTPBasicAuthHandler, and my script installs the handler. 

I'm not deep into the inner workings of urllib2 and mechanize - any pointer would be helpful. 

Regards, 
Andrew



More information about the twill mailing list