[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I set up proxy authentication using Python urllib2?

Posted on 2008-10-09
1
Medium Priority
?
5,098 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

649 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