ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: Proxy Authentication using urllib2
by John J. Lee other posts by this author
Sep 21 2003 9:43PM messages near this date
python-dev Summary for 2003-09-01 through 2003-09-15 | Where to publish my code
Andre Bocchini <lists@[...].com>  writes:

>  I'm having some trouble using proxy authentication.  I can't figure
>  out how to authenticate with a Squid proxy.  I know for a fact the
>  proxy is using Basic instead of Digest for the authentication.  I can
>  authenticate just fine using Mozilla.  I've done some Google searches,
>  but the closest piece of code I've is is for HTTPBasicAuthHandler:
[...]
>  proxy_handler = urllib2.ProxyHandler({"http" : "http://myproxy:3128"})
>  proxy_auth_handler = urllib2.ProxyBasicAuthHandler()
>  proxy_auth_handler.add_password(None, "myproxy", "myname", "mypass")
>  opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
>  urllib2.install_opener(opener)
>  f = urllib2.urlopen("http://www.python.org")
>  data = f.readlines()

Can't see anything wrong with that.


>  I always get a 407 error.

Are you sure you don't need a realm?  Try sniffing what Mozilla and
Python are sending (using eg. ethereal).  You *should* get a 407
response, IIRC, but then urllib2 should respond with an appropriate
Proxy-authorization header.

If that helped, please look at the doc patch here

http://www.python.org/sf/798244


test it, and post a comment to say whether or not it worked (and which
examples you tried -- preferably all of them ;).


John
-- 
http://mail.python.org/mailman/listinfo/python-list

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved