Skip to main content

requests-ntlm2

Build Status Python Version PyPI Status Licence

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

Usage

Basic Usage

HttpNtlmAuth extends requests AuthBase, so usage is simple:

import requests
from requests_ntlm2 import HttpNtlmAuth

auth=HttpNtlmAuth('domain\\username','password')
requests.get("http://ntlm_protected_site.com", 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')
session.get('http://ntlm_protected_site.com')

HTTPS CONNECT Usage

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:/foobar.com'

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)

Installation

pip install requests-ntlm2

Requirements

Download files

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

Source Distribution

requests_ntlm2-6.0.4.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file requests_ntlm2-6.0.4.tar.gz.

File metadata

  • Download URL: requests_ntlm2-6.0.4.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.1

File hashes

Hashes for requests_ntlm2-6.0.4.tar.gz
Algorithm Hash digest
SHA256 c208b5e886f1f4a6c98742e0120f4fa2a984f5f190532d55da47ede03fcaccbb
MD5 4a029db6c071daec0a63f559d17929a1
BLAKE2b-256 0e835abf84725835624a645d8979e96d86050479c8a49a2a653d9e8dbfd26ed2

See more details on using hashes here.

Release history Release notifications | RSS feed

6.6.0

2 files

6.5.3

2 files

6.5.2

2 files

6.5.1

2 files

6.5.0

2 files

6.4.4

2 files

6.4.3

2 files

6.4.2

2 files

6.4.1

2 files

6.4.0

2 files

6.3.1

2 files

6.3.0

2 files

6.2.11

2 files

6.2.10

2 files

6.2.9

2 files

6.2.8

2 files

6.2.7

2 files

6.2.6

2 files

6.2.5

2 files

6.2.4

2 files

6.2.3

2 files

6.2.2

2 files

6.2.1

2 files

6.2.0

2 files

6.1.2

2 files

6.1.1

2 files

6.1.0

3 files

6.0.13

3 files

6.0.12

3 files

6.0.11

3 files

6.0.10

1 file

6.0.9

1 file

6.0.8

1 file

6.0.7

1 file

6.0.6

1 file

6.0.5

1 file

This release

6.0.4 This release

1 file

6.0.3

1 file

6.0.2

1 file

0.0.80

1 file

0.0.79

1 file

0.0.78

1 file

0.0.77

1 file

0.0.76

1 file

0.0.75

1 file

0.0.74

1 file

0.0.73

1 file

0.0.72

1 file

0.0.71

1 file

0.0.70

1 file

0.0.55

1 file

0.0.54

1 file

0.0.53

1 file

0.0.52

1 file

0.0.51

1 file

0.0.50

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page