Registry / http-networking / httpx-ntlm

httpx-ntlm

JSON →
library1.4.0pypypi✓ verified 84d ago

httpx-ntlm is a Python package that provides NTLM (NT LAN Manager) authentication support for the HTTPX asynchronous HTTP client library. As of version 1.4.0, it allows users to authenticate against NTLM-protected resources, adapting functionality from the requests-ntlm library. It maintains an active status with infrequent but relevant updates.

pip install httpx-ntlm
INSTALL
IMPORT
SIG · HTTPX-NTLM
H
httpx-ntlm
http-networkingpythonv1.4.0
Install
3.1s avg
Import
581ms
Disk
38MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.596s · 39.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.1s · import 0.565s · 40MB
38MB installed
● package 38MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpNtlmAuth
from httpx_ntlm import HttpNtlmAuth

This quickstart demonstrates basic NTLM authentication using `httpx-ntlm` with both a direct `httpx.get` call and a more efficient `httpx.Client` instance for connection pooling. Remember to replace the placeholder URL and set NTLM_USERNAME and NTLM_PASSWORD environment variables with actual credentials.

import httpx from httpx_ntlm import HttpNtlmAuth import os # Using direct request (less efficient for multiple requests) response = httpx.get( "http://ntlm_protected_site.com", auth=HttpNtlmAuth(os.environ.get('NTLM_USERNAME', 'domain\\username'), os.environ.get('NTLM_PASSWORD', 'password')) ) print(f"Direct request status: {response.status_code}") # Using httpx.Client for connection pooling (recommended for multiple requests) with httpx.Client( auth=HttpNtlmAuth(os.environ.get('NTLM_USERNAME', 'domain\\username'), os.environ.get('NTLM_PASSWORD', 'password')) ) as client: response = client.get('http://ntlm_protected_site.com/resource') print(f"Client request status: {response.status_code}")
Debug
Known issues
breakinghttpx-ntlm version 1.4.0 introduced a minimum dependency on httpx version 0.24. If you are using an older version of httpx, you will encounter dependency resolution errors or runtime issues.
fix
Upgrade your httpx library to version 0.24 or higher: `pip install --upgrade httpx`.
affects: >=1.4.0
gotchaNTLM authentication is connection-based. For optimal performance and to avoid repeated authentication handshakes, it is highly recommended to use `HttpNtlmAuth` with an `httpx.Client` instance rather than passing `auth` to individual `httpx.get()` or `httpx.post()` calls.
fix
Instantiate `httpx.Client(auth=HttpNtlmAuth(...))` and use the client for subsequent requests: `client.get(...)`.
affects: all
deprecatedNTLM is an old and less secure authentication protocol. Microsoft has announced plans to disable NTLM by default in future Windows versions, making it an eventual target for deprecation across many systems. While `httpx-ntlm` functions correctly, consider migrating to more modern and secure authentication methods like Kerberos if available in your environment.
fix
Evaluate alternatives like Kerberos for authentication, or ensure NTLM remains explicitly enabled and secured in your server environment (if outside your control).
affects: all
Errors
Common errors & fixes
httpx.HTTPStatusError: Client Error: 401 Unauthorized for url: http://ntlm_protected_site.com
The provided NTLM username or password is incorrect, or the username format (e.g., 'domain\username') is not matching the server's expectation.
fix
Verify credentials, including the domain part, and ensure they are correct. Double-check for typos or incorrect domain separators.
ModuleNotFoundError: No module named 'httpx_ntlm'
The `httpx-ntlm` library has not been installed in the current Python environment.
fix
Install the package using pip: `pip install httpx-ntlm`.
AttributeError: module 'httpx_ntlm' has no attribute 'HttpNtlmAuth'
There is a typo in the class name or an incorrect import. The main authentication class is `HttpNtlmAuth`.
fix
Correct the import statement to `from httpx_ntlm import HttpNtlmAuth` and ensure the class name `HttpNtlmAuth` is used correctly.
Upgrade
Version history
1.4.0latest on PyPI · released Nov 3, 2023
Audit
Dependencies
httpxrequiredCore HTTP client library that httpx-ntlm extends. Version 1.4.0 requires httpx >= 0.24.
pyspnegorequiredProvides the underlying NTLM protocol negotiation capabilities.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
httpx-ntlm — pip install httpx-ntlm · libregistry