title: How to pass proxy-authentication to python Requests module
body: <p>I'm working on existing python code that uses the <strong>request</strong> module to perform get/post towards a web site.</p>
  
  <p>The python code also allow the use of proxies when a proxy is passed to the script otherwise no proxies are used.</p>
  
  <p>My problem regards the use of proxies that requires <strong>authentication</strong>.</p>
  
  <pre><code>proxy = user:password@ip:port
  self.s = requests.Session()
  if proxy != "":
        self.proxies = {
          "http": "http://" + proxy,
          "https": "https://" + proxy
        }
        self.s.proxies.update(proxies)
  
  self.s.get('http://checkip.dyndns.org')
  </code></pre>
  
  <p>In the code above, if the proxy is configured each <strong>get</strong> is refused because no authentication is provided.</p>
  
  <p>I found a solution that implies the use of HTTPProxyAuth.</p>
  
  <p>This is the solution that I found:</p>
  
  <pre><code>import requests
  s = requests.Session()
  
  proxies = {
    "http": "http://ip:port",
    "https": "https://ip:port"
  }
  
  auth = HTTPProxyAuth("user", "pwd")
  ext_ip = s.get('http://checkip.dyndns.org', proxies=proxies, auth=auth)
  print ext_ip.text
  </code></pre>
  
  <p>My question is: is it possibile to set the proxy authorization globally instead of modify each <strong>s.get</strong> in the code? Because sometime the script could be used without proxy and sometimes with proxy.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Best Regards,
  Federico</p>