I am working on an environment with NTLM proxy authentication and I want to implement HTTP communication in python. The program is an in-house development that will run on several computers, not just my own.
While the solution mentioned on this web page (Python 3 - urllib, HTTP Error 407: Proxy Authentication Required) allows this, it requires to input user name and password. My requirement is that the python program must use the established session, where user already authenticated as the program must work on several endpoints I don“t know their passwords so this is not an option.
I have been successful in writing the following powershell script that is able to do this. It will automatically. GetsystemWebProxy will automatically determine the defined proxy and, defaultcredentials will use the credentials from the current established session.
$url="https://weather.yahoo.com/"
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc = new-object system.net.webclient
$wc.proxy = $proxy
$wc.downloadString($url)
Porting the application to power shell would be time consuming. How can achieve the same in python?