{"id":18803401,"url":"https://github.com/dopstar/requests-ntlm2","last_synced_at":"2025-04-13T18:34:29.380Z","repository":{"id":46096636,"uuid":"230412518","full_name":"dopstar/requests-ntlm2","owner":"dopstar","description":"deep-copied from https://github.com/requests/requests-ntlm and then modified","archived":false,"fork":false,"pushed_at":"2023-08-01T14:45:26.000Z","size":244,"stargazers_count":11,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T09:12:51.800Z","etag":null,"topics":["ntlm","ntlm-authentication","ntlm-dance","proxy","python-library","requests"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dopstar.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-27T09:19:33.000Z","updated_at":"2023-11-23T04:01:47.000Z","dependencies_parsed_at":"2024-11-07T22:38:23.468Z","dependency_job_id":"c4d6867e-6e97-48dd-96e8-5abc34c83bee","html_url":"https://github.com/dopstar/requests-ntlm2","commit_stats":{"total_commits":193,"total_committers":31,"mean_commits":6.225806451612903,"dds":0.689119170984456,"last_synced_commit":"84341eda13ee2882f845dfacf3615178818688f1"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopstar%2Frequests-ntlm2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopstar%2Frequests-ntlm2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopstar%2Frequests-ntlm2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopstar%2Frequests-ntlm2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dopstar","download_url":"https://codeload.github.com/dopstar/requests-ntlm2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514211,"owners_count":21116899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ntlm","ntlm-authentication","ntlm-dance","proxy","python-library","requests"],"created_at":"2024-11-07T22:35:02.520Z","updated_at":"2025-04-13T18:34:29.354Z","avatar_url":"https://github.com/dopstar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003erequests-ntlm2\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003eNTLM authentication plugin for Requests\u003c/div\u003e\n\u003cbr /\u003e\n\n[![Build Status](https://github.com/dopstar/requests-ntlm2/workflows/build/badge.svg?branch=master)](https://github.com/dopstar/requests-ntlm2/actions?query=workflow%3Abuild)\n[![codecov](https://codecov.io/gh/dopstar/requests-ntlm2/branch/master/graph/badge.svg)](https://codecov.io/gh/dopstar/requests-ntlm2)\n[![Python Version](https://img.shields.io/pypi/pyversions/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![PyPI Status](https://img.shields.io/pypi/v/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![Downloads](https://img.shields.io/pypi/dm/requests-ntlm2.svg)](https://pypi.python.org/pypi/requests-ntlm2)\n[![Licence](https://img.shields.io/github/license/dopstar/requests-ntlm2.svg)](https://raw.githubusercontent.com/dopstar/requests-ntlm2/master/LICENSE)\n[![Code Style: Black](https://img.shields.io/badge/code%20style-black-101010.svg)](https://github.com/psf/black)\n\nrequests-ntlm2, which is based on [requests-ntlm](https://github.com/requests/requests-ntlm), allows for HTTP NTLM authentication using the requests library.\n\n## Installation\n\n```shell\npip install requests-ntlm2\n```\n\n## Usage\n\n### Basic Usage\n`HttpNtlmAuth` extends requests `AuthBase`, so usage is simple:\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth\n\nauth=HttpNtlmAuth('domain\\\\username','password')\nrequests.get(\"http://ntlm_protected_site.com\", auth=auth)\n```\n___\n\n### Changing NTLM compatibility level\nSee this [MS doc](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/cc960646%28v=technet.10%29) on LM compatibility levels. `requests_ntlm2` defaults to\ncompatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:\n\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth, NtlmCompatibility\n\nusername = 'domain\\\\username'\npassword = 'password123'\nntlm_compatibility = NtlmCompatibility.LM_AND_NTLMv1_WITH_ESS  # =\u003e level 1\nauth=HttpNtlmAuth(username, password, ntlm_compatibility=ntlm_compatibility)\n\nrequests.get(\"http://ntlm_protected_site.com\", auth=auth)\n```\n___\n\n### Using with Requests Session\n`HttpNtlmAuth` can be used in conjunction with a `Session` in order to\nmake use of connection pooling. Since NTLM authenticates connections,\nthis is more efficient. Otherwise, each request will go through a new\nNTLM challenge-response.\n\n```python\nimport requests\nfrom requests_ntlm2 import HttpNtlmAuth\n\nsession = requests.Session()\nsession.auth = HttpNtlmAuth('domain\\\\username','password')\nsession.get('http://ntlm_protected_site.com')\n```\n___\n\n### HTTP CONNECT Usage\nWhen using `requests-ntlm2` to create SSL proxy tunnel via\n[HTTP CONNECT](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_method), the so-called\n\"NTLM Dance\" - ie, the NTLM authentication handshake - has to be done at the lower level\n(at `httplib` level) at tunnel-creation step. This means that you should use the `HttpNtlmAdapter`\nand requests session. This `HttpNtlmAdapter` is responsible for sending proxy auth information\ndownstream. \n\nHere is a basic example:\n\n```python\nimport requests\nfrom requests_ntlm2 import (\n    HttpNtlmAuth,\n    HttpNtlmAdapter,\n    NtlmCompatibility\n)\n\nusername = '...'\npassword = '...'\nproxy_ip = '...'\nproxy_port = '...'\n\nproxies = {\n    'http': 'http://{}:{}'.format(proxy_ip, proxy_port),\n    'https': 'http://{}:{}'.format(proxy_ip, proxy_port)\n}\n\nntlm_compatibility = NtlmCompatibility.NTLMv2_DEFAULT\n\nsession = requests.Session()\nsession.mount(\n    'https://',\n    HttpNtlmAdapter(\n        username,\n        password,\n        ntlm_compatibility=ntlm_compatibility\n    )\n)\nsession.mount(\n    'http://',\n    HttpNtlmAdapter(\n        username,\n        password,\n        ntlm_compatibility=ntlm_compatibility\n    )\n)\nsession.auth = HttpNtlmAuth(\n    username,\n    password,\n    ntlm_compatibility=ntlm_compatibility\n)\nsession.proxies = proxies\n\nresponse = session.get('http:/foobar.com')\n```\n\n## Requirements\n\n- [requests](https://github.com/kennethreitz/requests/)\n- [ntlm-auth](https://github.com/jborean93/ntlm-auth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopstar%2Frequests-ntlm2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdopstar%2Frequests-ntlm2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopstar%2Frequests-ntlm2/lists"}