The HTTP NTLM proxy and/or server authentication library.
Project description
requests-ntlm3
requests-ntlm3, 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_ntlm3 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_ntlm3 import HttpNtlmAuth
session = requests.Session()
session.auth = HttpNtlmAuth('domain\\username','password')
session.get('http://ntlm_protected_site.com')
HTTPS CONNECT Usage
When using requests-ntlm3
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_ntlm3 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-ntlm3
Requirements
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for requests_ntlm3-6.0.11b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e2c9ab553990b476f3767e717783bb67ff49b4022336523b0f800e6cc39dcb |
|
MD5 | 207e8c9bd857063ad6ad3ea20ff7ee33 |
|
BLAKE2b-256 | 716562de0f349e5cdaa5c312277174208a2f5d38c7d7fe3c0794af7e0f725a7c |
Hashes for requests_ntlm3-6.0.11b2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58938b1b7cfd2e84bfae2a0b6881d30f43338251c4420bd7dae97c3352c6f8bc |
|
MD5 | 4f5416b4decd958359622d2e2892e894 |
|
BLAKE2b-256 | a6ab4d32273ed176759a93e784d6ba17b408bd77439c9abeede170f3919b6145 |