The HTTP NTLM proxy and/or server authentication library.
Project description
requests-ntlm2
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
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_ntlm2-6.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 638784dd89f49e56e000ca1a9213d24ff652ff5db3c430cf636c2889cc4c1578 |
|
MD5 | 0b8d01e30b1452dcfd2b7f0ef3c5e871 |
|
BLAKE2b-256 | e81c0f82b4e21ad85b08017dd7c732a34e3228f54c636f5602a5cea564213ec5 |
Hashes for requests_ntlm2-6.0.11-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c502edcc3687e047c38f682879db1d4038108f07e1f6e113314e92cdc555fc6 |
|
MD5 | 328ed236501072f0e839366db77b6fdd |
|
BLAKE2b-256 | 476b29fb373b416bc7da475891a79a1707c167250f98d147a1e8d0f90badf7d7 |