Solved

How do I set up proxy authentication using Python urllib2?

Posted on 2008-10-09
1
4,885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
PaulKeating earned 0 total points
ID: 22685229
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

763 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