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
Metadata
Release files for requests-ntlm2 6.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| requests_ntlm2-6.0.4.tar.gz | 9.6 kB | Without provenance | Details |
Release files / requests_ntlm2-6.0.4.tar.gz
| Download URL | requests_ntlm2-6.0.4.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c208b5e886f1f4a6c98742e0120f4fa2a984f5f190532d55da47ede03fcaccbb
|
|
BLAKE2b-256 checksum How to use checksums |
0e835abf84725835624a645d8979e96d86050479c8a49a2a653d9e8dbfd26ed2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for requests-ntlm2 6.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.