Skip to content

Commit f251100

Browse files
authored
Merge pull request #110 from Aisbergg/feature-ntlm-authentication
Add NTLM authentication
2 parents 71d3b08 + d5cffe7 commit f251100

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
# Environments
7+
.env
8+
.venv
9+
env/
10+
venv/
11+
ENV/
12+
env.bak/
13+
venv.bak/
14+
615
# C extensions
716
*.so
817

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from office365.runtime.auth.network_credential_context import NetworkCredentialContext
2+
3+
try:
4+
from requests_ntlm import HttpNtlmAuth
5+
except ImportError:
6+
raise ImportError("To use NTLM authentication the package 'requests_ntlm' needs to be installed")
7+
8+
9+
class NTLMAuthenticationContext(NetworkCredentialContext):
10+
"""Provides NTLM authentication"""
11+
12+
def __init__(self, username, password):
13+
super(NTLMAuthenticationContext, self).__init__(username, password)
14+
self.auth = HttpNtlmAuth(*self.userCredentials)
15+
16+
def authenticate_request(self, request_options):
17+
request_options.auth = self.auth

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requests
2+
requests_ntlm [NTLMAuthentication]
3+
setuptools

setup.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
long_description_content_type="text/markdown",
2121
url="https://github.com/vgrem/Office365-REST-Python-Client",
2222
install_requires=['requests'],
23+
extras_require={
24+
'NTLMAuthentication': ["requests_ntlm"],
25+
},
2326
tests_require=['nose'],
2427
test_suite='nose.collector',
2528
license="MIT",

0 commit comments

Comments
 (0)