Proxy authentication in common libraries

S

Sahasranaman

Hi

I am behind a proxy server that needs proxy authentication. There are
a lot of libraries that come without proxy support. The function
below, which is part of the python-twitter library does HTTP
Authentication, and I can't figure out how to do this with a
ProxyBasicAuthHandler object. I'm pasting the function here. Can
someone tell me how this code can be rewritten to do proxy
authentication as well as http authentication?

def _GetOpener(self, url, username=None, password=None):
if username and password:
self._AddAuthorizationHeader(username, password)
handler = self._urllib.HTTPBasicAuthHandler()
(scheme, netloc, path, params, query, fragment) =
urlparse.urlparse(url)
handler.add_password(Api._API_REALM, netloc, username, password)
opener = self._urllib.build_opener(handler)
else:
opener = self._urllib.build_opener()
opener.addheaders = self._request_headers.items()
return opener
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top