# Webservices NTLM Auth

**URL:** <https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656>\
**Category:** General Discussion\
**Created:** [February 8, 2017, 2:15pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656 "2017-02-08T14:15:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [February 8, 2017, 2:15pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/1 "2017-02-08T14:15:30Z")

</div>

I am working on a project that will integrate Ignition with SharePoint 2013 and another one of our systems.

I am attempting to setup Ignition with REST services to SharePoint. This works great for reading, however I am having issues posting data. It appears to boil down to the need to use NTLM auth. The [system.net](http://system.net).\* functions do what we need otherwise.

I did a trial of the SepaSoft Web Services Module and it it works OOB for what I need, but the $2500 cost (times many gateways…) is going to be a hard sell to my management just to add the ability to do NTLM auth to a web service.

I have tried using the requests-ntlm python module, but unfortunately this is only python 2.6+ compatible and errors out in jython. Any other ideas?

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [April 4, 2017, 2:12pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/2 "2017-04-04T14:12:02Z")

</div>

I do not think NTLM is the only auth method for SP.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [April 4, 2017, 2:46pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/3 "2017-04-04T14:46:34Z")

</div>

It’s not, but I don’t have any control over our SharePoint environment and the team that owns it is not very receptive to changes.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 4, 2017, 2:59pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/4 "2017-04-04T14:59:30Z")

</div>

You could try using Java’s HttpURLConnection directly: [docs.oracle.com/javase/8/docs/a … ction.html](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html)

It may support NTLM auth as of Java 8.

---

<div class="post-metadata">

**Author:** ![mark.french](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mark.french/32/4781_2.png) [@mark.french](https://forum.inductiveautomation.com/u/mark.french)\
**Post date:** [April 28, 2017, 5:13pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/5 "2017-04-28T17:13:44Z")

</div>

HI Ryan,

Did you find a solution here? If you’re still working on it, feel free to give me a call and we can discuss bulk pricing if that is the barrier to using our Webservices module.

Best regards,  
Mark  
800.207.5506x107

P.S. Sorry - we don’t closely monitor the IA forum…I might have to change that!

---

<div class="post-metadata">

**Author:** ![dmdrendall](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@dmdrendall](https://forum.inductiveautomation.com/u/dmdrendall)\
**Post date:** [January 4, 2018, 2:32am UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/6 "2018-01-04T02:32:45Z")

</div>

Or this?

[JXBrowser example code](https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013139-handling-basic-digest-and-ntlm-authentication)

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [March 10, 2020, 6:08pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/7 "2020-03-10T18:08:09Z")

</div>

Wondering if there are any new ways to handle this using the new system.net.httpClient() to allow an NTLM auth? It seems there is more exposure to the Java objects, but the java docs for httpclient go down a rabbit hole real quick.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 10, 2020, 6:21pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/8 "2020-03-10T18:21:17Z")

</div>

Right now `system.net.httpClient` just uses the Java HTTPClient, which, at least in Java 11, only supports Basic authentication. Either our implementation or Java’s may change in the future. Could be an ideas post, if it’s not already 🙂

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [March 16, 2020, 3:42pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/9 "2020-03-16T15:42:01Z")

</div>

After some playing around I was able to setup a basic HTTP GET using Java and supplying NTLM auth.

However, I am finding that I am getting import errors in the Gateway Scope, but not in the Designer scope. I am running the same Java (8.231) on both designer and gateway, is there some odd difference in context of why the below might fail?

```auto
# Perform a basic HTTP Get to the provided URL using the NTLM auth in the function
def _httpGetNTLM(url):	
	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
	
	# Setup the client with NTLM Auth
	httpclient = DefaultHttpClient()
	
	# Define the credentials to use
	creds = NTCredentials("USERNAME", "PASSWORD", system.net.getHostName(), "DOMAINHERE")
	httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds)
	
	# Define the host and URL to call
	httpget = HttpGet(url)
	
	# Execute the request
	response = httpclient.execute(httpget)   
	
	# Handle the response
	content = BasicResponseHandler().handleResponse(response)
	contentType = ContentType.getOrDefault(response.getEntity()).getMimeType()
	
	# Return the result
	if 'json' in contentType.lower():
		return system.util.jsonDecode(content)
	else:
		return content

```

Results return fine in the Designer (script console). On the gateway, I get the following:

```auto
Traceback (most recent call last):
...
...
File "", line 33, in _httpGetNTLM
ImportError: No module named http

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 16, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/10 "2020-03-16T15:52:32Z")

</div>

Look in the vision module file. You’ll see httpclient and httpcore JAR files set to deploy in Client and Designer scopes. These aren’t part of the common gateway in v7.9.

They _are_ part of the common gateway in v8.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [March 16, 2020, 4:32pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/11 "2020-03-16T16:32:21Z")

</div>

That makes sense, I assume there would not be a workaround? Can I drop the JARs in common to force to all scopes?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 16, 2020, 4:46pm UTC](https://forum.inductiveautomation.com/t/webservices-ntlm-auth/12656/12 "2020-03-16T16:46:42Z")

</div>

You can try 🙂  
It’s unsupported and you could cause other issues for yourself, especially if there are any version mismatches.
