Automatic NTLM with python on Windows

Viewed 12783

How can I use automatic NTLM authentication from python on Windows?

I want to be able to access the TFS REST API from windows without hardcoding my password, the same as I do from the web browser (firefox's network.automatic-ntlm-auth.trusted-uris, for example).

4 Answers

I found solution here https://github.com/mullender/python-ntlm/issues/21

pip install requests
pip install requests_negotiate_sspi
import requests
from requests_negotiate_sspi import HttpNegotiateAuth

GetUrl = "http://servername/api/controller/Methodname" # Here you need to set your get Web api url
response = requests.get(GetUrl, auth=HttpNegotiateAuth())
print("Get Request Outpot:")
print("--------------------")
print(response.content)

for request by https:

import requests
from requests_negotiate_sspi import HttpNegotiateAuth

import urllib3
urllib3.disable_warnings()

GetUrl = "https://servername/api/controller/Methodname" # Here you need to set your get Web api url
response = requests.get(GetUrl, auth=HttpNegotiateAuth(), verify=False)
print("Get Request Outpot:")
print("--------------------")
print(response.content)
Related