python module requests_ntlm

Understanding python module requests_ntlm

Python is a versatile language that offers a wide range of libraries and modules that make it easy to perform tasks, including web scraping and API integration. One such module is requests_ntlm, which is used to handle NTLM authentication in Python.

What is NTLM?

NTLM (Windows NT LAN Manager) is a proprietary authentication protocol developed by Microsoft. It is used to authenticate users in a Windows domain and allows users to access resources on a network, such as printers and files. NTLM is an outdated protocol and has been replaced by Kerberos, but it is still widely used in legacy systems.

What is requests_ntlm?

requests_ntlm is a Python module that allows you to authenticate with NTLM using the requests library. It wraps the requests library's HTTP authentication support and provides a simple interface for working with NTLM authentication.

How to use requests_ntlm?

To use requests_ntlm, you first need to install it using pip:

        pip install requests-ntlm

Once installed, you can import it into your Python script:

        import requests
        from requests_ntlm import HttpNtlmAuth

Now you can use the HttpNtlmAuth class to authenticate with NTLM:

        response = requests.get(url, auth=HttpNtlmAuth('domain\\username', 'password'))

The HttpNtlmAuth class takes two arguments - the domain and username, and the password. You can also use the requests.Session object to maintain the authentication across multiple requests:

        session = requests.Session()
        session.auth = HttpNtlmAuth('domain\\username', 'password')
        response = session.get(url)


The requests_ntlm module is a useful tool for working with NTLM authentication in Python. It provides a simple interface for working with NTLM and allows you to easily authenticate with a Windows domain. By using requests_ntlm, you can save time and effort in handling NTLM authentication in your Python projects.