Question: 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/>,

<https://stackoverflow.com/questions/25764595/accessing-sharepoint-site-in-python-with-windows-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.

Answer: 
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.
The other two options you could give a try are Kerberos or Basic Authentication:

**Kerberos:**

```
import requests
from requests_negotiate_sspi import HttpNegotiateAuth

cert = 'path\to\certificate.cer'

response = requests.get(
    r'http://mysharepoint.com/_api',
    auth=HttpNegotiateAuth(),
    verify=cert)

print(response.status_code)

```

**Basic:**

```
import requests
from requests.auth import HTTPBasicAuth

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

response = requests.get(
    url=r'http://mysharepoint.com/_api',
    auth=HTTPBasicAuth(user, password),
    verify=cert)

print(response.status_code)

```

Source: [Link](https://qurios-it.de/2020/10/16/connecting-to-sharepoint-using-python/)