Solved

How do I set up proxy authentication using Python urllib2?

Posted on 2008-10-09
1
4,729 Views
Last Modified: 2012-06-21
I am trying to access a website on my corporate intranet from a Python program.
The intranet is set up to use a proxy server and the proxy server requires authentication.
>>> try:
...       urllib2.urlopen("http://lmaprda01:8080/etc/etc")
... except IOError, e:
...       print e.headers
...       
Via: 1.1 GIPPRDW02
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 4112  

I've read the urllib2 howto on python.org but it shows how to authenticate on the site not on the proxy and the proxy example is too sketchy for me to figure it out.
Part of the problem may be that I don't really know my username. Is it Windows-style domain\username or does the domain live in the realm? And if not how can I find out what the realm is?
0
Comment
Question by:PaulKeating
1 Comment
 
LVL 5

Accepted Solution

by:
PaulKeating earned 0 total points
Comment Utility
A colleague points out that since the url is on the corporate intranet I should not be going through a proxy. Instead I should knock out the proxy handler, which is described in the howto on python.org
>>> proxy_support = urllib2.ProxyHandler({})
>>> opener = urllib2.build_opener(proxy_support)
>>> urllib2.install_opener(opener)
>>> urllib2.urlopen('http:// etc')
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Common practice undertaken by most system administrators is to document the configurations and final solutions of anything performed by them for their future use and reference. So here I am going to explain how to export ISA Server 2004 Firewall pol…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now