{"id":8221,"library":"httpx-ntlm","title":"HTTP NTLM authentication for HTTPX","description":"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.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/ulodciv/httpx-ntlm","tags":["httpx","ntlm","authentication","http","networking","windows","security"],"install":[{"cmd":"pip install httpx-ntlm","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core HTTP client library that httpx-ntlm extends. Version 1.4.0 requires httpx >= 0.24.","package":"httpx","optional":false},{"reason":"Provides the underlying NTLM protocol negotiation capabilities.","package":"pyspnego","optional":false}],"imports":[{"symbol":"HttpNtlmAuth","correct":"from httpx_ntlm import HttpNtlmAuth"}],"quickstart":{"code":"import httpx\nfrom httpx_ntlm import HttpNtlmAuth\nimport os\n\n# Using direct request (less efficient for multiple requests)\nresponse = httpx.get(\n    \"http://ntlm_protected_site.com\",\n    auth=HttpNtlmAuth(os.environ.get('NTLM_USERNAME', 'domain\\\\username'), os.environ.get('NTLM_PASSWORD', 'password'))\n)\nprint(f\"Direct request status: {response.status_code}\")\n\n# Using httpx.Client for connection pooling (recommended for multiple requests)\nwith httpx.Client(\n    auth=HttpNtlmAuth(os.environ.get('NTLM_USERNAME', 'domain\\\\username'), os.environ.get('NTLM_PASSWORD', 'password'))\n) as client:\n    response = client.get('http://ntlm_protected_site.com/resource')\n    print(f\"Client request status: {response.status_code}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your httpx library to version 0.24 or higher: `pip install --upgrade httpx`.","message":"httpx-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.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"Instantiate `httpx.Client(auth=HttpNtlmAuth(...))` and use the client for subsequent requests: `client.get(...)`.","message":"NTLM 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Evaluate alternatives like Kerberos for authentication, or ensure NTLM remains explicitly enabled and secured in your server environment (if outside your control).","message":"NTLM 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.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify credentials, including the domain part, and ensure they are correct. Double-check for typos or incorrect domain separators.","cause":"The provided NTLM username or password is incorrect, or the username format (e.g., 'domain\\username') is not matching the server's expectation.","error":"httpx.HTTPStatusError: Client Error: 401 Unauthorized for url: http://ntlm_protected_site.com"},{"fix":"Install the package using pip: `pip install httpx-ntlm`.","cause":"The `httpx-ntlm` library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'httpx_ntlm'"},{"fix":"Correct the import statement to `from httpx_ntlm import HttpNtlmAuth` and ensure the class name `HttpNtlmAuth` is used correctly.","cause":"There is a typo in the class name or an incorrect import. The main authentication class is `HttpNtlmAuth`.","error":"AttributeError: module 'httpx_ntlm' has no attribute 'HttpNtlmAuth'"}]}