title: Integrate Python Urllib2 with Windows Authentication using NTLM SSPI
body: <p>This is a follow up question from the below answer: </p>
  
  <p><a href="https://stackoverflow.com/questions/34991883/authorise-with-current-user-credentials-for-python-script-accessing-sharepoint-l/35637023">Authorise with current user credentials for Python script accessing SharePoint list using NTLM</a></p>
  
  <p>I am trying to interface with a SharePoint list without passing or hard-coding a password in my script. </p>
  
  <p>The solution provided in the previous answer works successfully with the requests library, however I am unable to integrate it into the urllib2 function that I use to interface with SharePoint. </p>
  
  <p>The function below currently works with a hard-coded password, but I would prefer to use SSPI authentication so as not to embed the pw in the script. </p>
  
  <pre><code>def read_sharepoint_list(current_project):
      username = "Domain\\user.name"
      password = "my_password"
  
      # the sharepoint info
      site_url = "http://SharePoint/"
      list_name = "My List"
  
      # an opener for the NTLM authentication
      passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
      passman.add_password(None, site_url, username, password)
      auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
  
      # create and install the opener
      opener = urllib2.build_opener(auth_NTLM)
      urllib2.install_opener(opener)
  </code></pre>
  
  <p>I have focused my attempts to integrate on the <code>passman.addpassword()</code> component of the below function with no luck. </p>
  
  <p>I have replaced the password <code>HttpNtlmSspiAuth()</code> call.
  Also have replaced with the full requests string: <code>requests.get(site_url, auth=HttpNtlmSspiAuth())</code>. No luck with either. </p>
  
  <p>I have also tried to engage with the <code>auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)</code> line, but I am out of my depth. Reviewing the NTLM documentation has thus far not yielded a solution. </p>
  
  <p>Your thoughts and suggestions are much appreciated. </p>