# Download document from SharePoint (NTLM Authentication)

**URL:** <https://forum.inductiveautomation.com/t/download-document-from-sharepoint-ntlm-authentication/69474>\
**Category:** Ignition\
**Tags:** python, scripting\
**Created:** [February 6, 2023, 10:50am UTC](https://forum.inductiveautomation.com/t/download-document-from-sharepoint-ntlm-authentication/69474 "2023-02-06T10:50:55Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Matthew\_Farmer](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Matthew\_Farmer](https://forum.inductiveautomation.com/u/Matthew_Farmer)\
**Post date:** [February 13, 2023, 3:44pm UTC](https://forum.inductiveautomation.com/t/download-document-from-sharepoint-ntlm-authentication/69474/8 "2023-02-13T15:44:38Z")

</div>

Thanks @Matthew.gaitan that was the last part I needed

My final code:

```auto
# Perform a basic HTTP Get to the provided URL using the NTLM auth in the function
def DownloadFile(remoteFile, localFile):	
	from org.apache.http.auth import AuthScope
	from org.apache.http.auth import NTCredentials
	from org.apache.http.client.methods import HttpGet
	from org.apache.http.impl.client import DefaultHttpClient
	from org.apache.http.impl.client import BasicResponseHandler
	from org.apache.http.entity import ContentType
	from org.apache.http.util import EntityUtils
	
	# Setup the client with NTLM Auth
	httpclient = DefaultHttpClient()
	
	# Define the credentials to use
	creds = NTCredentials(username, password, system.net.getHostName(), domain)
	httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds)
	
	# Define the host and URL to call
	httpget = HttpGet(remoteFile)
	
	# Execute the request
	response = httpclient.execute(httpget)
	
	# Copy the file
	with open(localFile, "wb") as output_file:
		output_file.write(EntityUtils.toByteArray(response.getEntity()))

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/download-document-from-sharepoint-ntlm-authentication/69474)._
