title: Python Connect To Exchange /w Windows Auth
body: <p>I am trying to create a script in  <strong>Python 3.8</strong> script that can connect to an <strong>Exchange</strong> server and retrieve emails from a mailbox. I am trying to authenticate with <strong>Exchange</strong> by using the currently authenticated user. I can authenticate fine if I use a username and password. (Trying to not store any passwords or anything, just use the currently authenticated user.)</p>
  
  <p>I am using <strong>Python 3.8</strong> and <strong>Exchangelib</strong> to connect <strong>Exchange</strong> but cannot figure out how to use Windows Auth(If possible).</p>
  
  <p>Any help to try to accomplish this is appreciated.</p>
  
  <p>Thanks</p>
  
  <p>Example of what I'm trying to do:</p>
  
  <pre><code>from exchangelib import DELEGATE, IMPERSONATION, Account, Credentials, OAuth2Credentials, \
      OAuth2AuthorizationCodeCredentials, FaultTolerance, Configuration, NTLM, GSSAPI, SSPI, \
      OAUTH2, Build, Version
  from exchangelib.autodiscover import AutodiscoverProtocol
  
  exchange_email = 'mailboxIWantToAccess@domain.com'
  
  account = Account(exchange_email, autodiscover=True)
  # account = Account(exchange_email, credentials=credentials, autodiscover=True)
  
  account.root.refresh()
  account.public_folders_root.refresh()
  
  print(account.root.tree())
  </code></pre>
  
  <p>Error I am getting:</p>
  
  <pre><code>Traceback (most recent call last):
    File "c:/Users/jk354/Documents/git.ourgitserver.com/client-info/script-ex.py", line 233, in &lt;module&gt;
      account = Account(exchange_email, autodiscover=True)
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\account.py", line 85, in __init__
      self.ad_response, self.protocol = discover(
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\autodiscover\discovery.py", line 23, in discover
      return Autodiscovery(
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\autodiscover\discovery.py", line 88, in discover
      ad_protocol = autodiscover_cache[cache_key]
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\autodiscover\cache.py", line 97, in __getitem__
      protocol = AutodiscoverProtocol(config=Configuration(
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\protocol.py", line 73, in __init__
      self._session_pool = self._create_session_pool()
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\protocol.py", line 160, in _create_session_pool
      session_pool.put(self.create_session(), block=False)
    File "C:\Users\jk354\AppData\Local\Programs\Python\Python38-32\lib\site-packages\exchangelib\protocol.py", line 233, in create_session
      with self.credentials.lock:
  AttributeError: 'NoneType' object has no attribute 'lock'
  </code></pre>
  
  <p><a href="https://github.com/ecederstrand/exchangelib" rel="nofollow noreferrer">https://github.com/ecederstrand/exchangelib</a></p>