Skip to main content

The HTTP NTLM proxy and/or server authentication library.

Project description


Build Status codecov Python Version PyPI Status Downloads Licence

requests-ntlm2, which is based on requests-ntlm , allows for HTTP NTLM authentication using the requests library.


Basic Usage

HttpNtlmAuth extends requests AuthBase, so usage is simple:

import requests
from requests_ntlm2 import HttpNtlmAuth

requests.get("", auth=auth)

Using with Requests Session

HttpNtlmAuth can be used in conjunction with a Session in order to make use of connection pooling. Since NTLM authenticates connections, this is more efficient. Otherwise, each request will go through a new NTLM challenge-response.

import requests
from requests_ntlm2 import HttpNtlmAuth

session = requests.Session()
session.auth = HttpNtlmAuth('domain\\username','password')


When using requests-ntlm2 to create SSL proxy tunnel via HTTPS CONNECT, the so-called "NTLM Dance" - ie, the NTLM authentication handshake - has to be done at the lower level (at httplib level) at tunnel-creation step. This means that you should use the HttpNtlmAdapter and requests session. This HttpNtlmAdapter is responsible for sending proxy auth information downstream.

Here is a basic example:

import requests
from requests_ntlm2 import HttpNtlmAuth, HttpNtlmAdapter

username = '...'
password = '...'
proxy_ip = '...'
proxy_port = '...'

proxies = {
    'http': 'http://{}:{}'.format(proxy_ip, proxy_port),
    'https': 'http://{}:{}'.format(proxy_ip, proxy_port)

url = 'http:/'

session = requests.Session()
session.mount('https://', HttpNtlmAdapter(username, password))
session.mount('http://', HttpNtlmAdapter(username, password))
session.auth = HttpNtlmAuth(username, password)
session.proxies = proxies

response = session.get(url)


pip install requests-ntlm2


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for requests-ntlm2, version 6.0.10
Filename, size File type Python version Upload date Hashes
Filename, size requests_ntlm2-6.0.10.tar.gz (11.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page