proxy authentication: how to hide password
anthony_barker at hotmail.com
Tue Feb 12 17:18:51 CET 2002
> I'm using Python 2.2 on Win2k. We have a firewall in our organization,
> so I need to connect to the Internet via proxy from my .py scripts.
> So I use the following lines:
> f = urllib2.urlopen(url-to-retrieve)
> where login and passwd are my Windows login and password.
I am in a similar position, but luckily my password isn't in sync with
my windows password.
I tried sockscap without much success. But you will have to add your
password to sockscap anyways.
But don't feel bad - Perl has a similar issue - but uses an
environment variable instead. I also use wget - this uses the .wgetrc
(yet another location for the password).
> Everything works OK, but obviously there are some problems:
> - my password is stored in my script as a simple text;
use a local environment variable gets around this one (like perl).
>>> import os
>>> user = os.environ['USERNAME']
>>> password = os.environ['HTTP_proxy_pass']
> - I need to change my scripts regularly to correct the password;
> - my colleagues can't use the same script - they should change the
> login and password their.
prompt for the password if need be.
More information about the Python-list