Reputation: 3007
I am working on developing an API call which needs to authenticate to a proxy. I have managed to do this by explicitly entering my proxy information. Like so:
import requests
proxies = {'https': "https://user:password@proxyIP:port"}
response = requests.get('www.google.com', proxies=proxies)
The question is how do I grab the credentials of the currently logged in user and then pass them to the proxy. In my research I have come across this ServerFault post - the answer wasn't helpful but there is another one by shellster which seems to work. However, I cannot make sense of his code.
I have also install requests_negotiate_sspi
(docs) and attempted to leverage the HttpNegotiateAuth
module as mentioned here but I cannot seem to figure it out.
Note: I am using Python 3.7 and am in Windows 7 + 10 Environment.
EDIT
This question specifies proxies, however I really need to know how this works for other domain resources, like SharePoint, User Shares, etc.
There has to be a pythonic way to accomplish this!
Upvotes: 4
Views: 10103
Reputation: 1
The following worked for me when connecting to sharepoint using requests_negotiate_sspi:
import requests
from requests_negotiate_sspi import HttpNegotiateAuth
proxies = {'https': "https://user:password@proxyIP:port"}
response = requests.get('www.google.com', proxies=proxies, auth = HttpNegotiateAuth())
Upvotes: 0