This package enables HTTP NTLM authentication for the popular Python requests library. It provides a simple `HttpNtlmAuth` class that integrates seamlessly with `requests.Session` for handling NTLM challenges. The current version is 1.3.0, and it follows an active maintenance cadence with releases addressing compatibility, security, and minor enhancements.
pip install requests-ntlmVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `HttpNtlmAuth` with a `requests.Session`. It's crucial to correctly format the username (e.g., `DOMAIN\username` or `user@domain.com`) and provide the corresponding password. The example uses environment variables for sensitive data for security and convenience.
Ensure your code explicitly catches and handles exceptions for HTTP errors or access denied scenarios. Review code that previously might have processed an empty or error response without an explicit exception.
Upgrade to `requests-ntlm==1.3.0` or newer to ensure correct type annotation and `pyspnego` compatibility. This version sets the correct minimum `pyspnego` version (>=0.11.1).
Verify that `pyspnego` is correctly installed and meets the minimum version requirements. Test your NTLM integrations thoroughly after upgrading to v1.2.0 or newer.
Upgrade to `requests-ntlm==1.1.0` or newer if you are using UPNs for NTLM authentication. Alternatively, ensure your username is in the `DOMAIN\user` format for older versions.
Ensure your project's Python environment is running Python 3.8 or a later version. Use a tool like `pyenv` or virtual environments to manage Python versions.
pip install requests-ntlm
from requests_ntlm import HttpNtlmAuth
HttpNtlmAuth('your_username', 'your_password')from requests_ntlm import HttpNtlmAuth