I wrote a small script that goes through a bunch of folders and consolidates excel files.

Now I would like to use this script with files stored in our company sharepoint. Since getting support from our IT is not an option and I am looking to do this myself. I seem to get stuck at the authentication part though. Our sharepoint uses the windows credentials to connect to it, I dont have more information.

Any pointers would be helpful, I am gonna list some methods that I tried so far. Usually I get Error 401.

I tried: http://docs.python-requests.org/en/latest/user/authentication/,


I tried this code:

import requests
from requests_ntlm import HttpNtlmAuth
requests.get("http://sharepoint-site.com", auth=HttpNtlmAuth('DOMAIN\\USERNAME','PASSWORD'))

I dont know where to go from here, any pointers or ways to find out more information what type of authentication my sharepoint has would already be helpful.


If you are using SharePoint file libraries rather than lists you should just be able to give the server path to the file library as the folder path, instead of bothering with any SharePoint APIs.

For instance if your SharePoint site is SharePoint.Company.net/sites/sitename/LibraryName your server path to that Library might (as an example with SSL) be \\SharePoint.Company.net@SSL\sites\sitename\LibraryName.

This works on my company's.

The easiest way to get the correct path to use is to go to the library in IE and use the open with explorer button. Then use that URL to map the drive to a letter and the mapped details will then give the details you need. Then you can just reference that path like a normal folder path as if it was part of your local drives.

  • @Robert Lindgren Thanks for the reply. But this would propably also mean, that this script would already require an active sharepoint connection right? As in, I have to be logged in and at my pc to run this? – Tim Aug 22 '18 at 15:28
  • This worked well for me. I used forward slashes. – stevepastelan May 28 '20 at 21:02

The other two options you could give a try are Kerberos or Basic Authentication:


import requests
from requests_negotiate_sspi import HttpNegotiateAuth

cert = 'path\to\certificate.cer'
response = requests.get(



import requests
from requests.auth import HTTPBasicAuth

cert = 'path\to\certificate.cer'
user = 'DOMAIN\\User'
password = 'MyPassword'

response = requests.get(
    auth=HTTPBasicAuth(user, password),


Source: Link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.