# Script Console cryptography for HttpNtlmAuth requests.get Import Error

**URL:** <https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802>\
**Category:** Ignition\
**Created:** [February 24, 2025, 5:25pm UTC](https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802 "2025-02-24T17:25:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_Hitchcock](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@Drew\_Hitchcock](https://forum.inductiveautomation.com/u/Drew_Hitchcock)\
**Post date:** [February 24, 2025, 5:25pm UTC](https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802/1 "2025-02-24T17:25:50Z")

</div>

Struggling a bit trying to develop a HTTP get with domain authentication to work in Ignition. The end goal is to periodically read in a json from the API, parse out data, put it into a database for use by Ignition, and then post a modified file with some altered flags. After some research, I took a stab at using requests.get and HttpNtlmAuth from the requests\_ntlm library. I used pip to install requests and requests\_ntlm and their dependencies on my computer. I copied all the files from C:\Python27\Lib\site-packages to C:\Program Files\Inductive Automation\Ignition\user-lib\pylib, restarted the designer, and ran the following:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9c2997b0fbb474e31a0575b4ae893d5c3aa6b6d3.png)

Note that individual requests.get and HttpNtlmAuth run without python errors.

It would seem like cryptography is missing a file, but that file appears to be present in my ignition cache (C:\Users[me].ignition\cache\gwlocalhost\_8088\C0\pylib\site-packages\cryptography\hazmat\bindings top left), ignition site packages s (C:\Users[me].ignition\cache\gwlocalhost\_8088\C0\pylib\site-packages\cryptography\hazmat\bindings top right), and my local python site packages at C:\Python27\Lib\site-packages\cryptography\hazmat\bindings (bottom).

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/63c5be3a664b9abd5e427346ccdd6263505c043a.png)

The code works from the python command line (content of result is as expected):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7de843e667eddeb97b6228ef9e8f9a2c6d773540.jpeg)

I already tried the following:

1. Restarting designer
2. Deleting the C:\Users[me].ignition\cache directory
3. Editing and saving the C:\Users[me].ignition\cache\gwlocalhost\_8088\C0\pylib\site-packages\cryptography\hazmat\bindings\openssl\binding.py file after adding a whitespace in a commented line.

Any suggestions for fixing this import error or developing an API call that works like the one in my python command line would be much appreciated.

---

<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:** [February 24, 2025, 5:38pm UTC](https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802/2 "2025-02-24T17:38:10Z")

</div>

`.pyd` files are basically DLLs, and these don't work on Jython.

I think that Ignition still ships with the Apache HTTP client library in all scopes... your best bet might be to convert some sample code for using this library to Python/Jython, e.g. [rest - Http post requests unsing NTLM Authentication (java) - Stack Overflow](https://stackoverflow.com/a/42692997)

---

<div class="post-metadata">

**Author:** ![Drew\_Hitchcock](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@Drew\_Hitchcock](https://forum.inductiveautomation.com/u/Drew_Hitchcock)\
**Post date:** [February 24, 2025, 7:28pm UTC](https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802/3 "2025-02-24T19:28:26Z")

</div>

Thanks for the tip. Got something working. Here's a screenshot for posterity:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/d/3da1f32c8a22a708100c4303b52a87bea9b4e69a.png)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [February 24, 2025, 7:33pm UTC](https://forum.inductiveautomation.com/t/script-console-cryptography-for-httpntlmauth-requests-get-import-error/102802/4 "2025-02-24T19:33:34Z")

</div>

Post code, not pictures of code. It helps with searching via text. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). You can edit your post by clicking the pencil icon on the bottom right.

Edit: Code for those searching:

> **Original**
>
> ```python
> url = 'MY URL'
> un = 'MY USERNAME'
> do = 'MY DOMAIN'
> pwd = 'MY PASSWORD'
> 
> # Import
> import org.apache.http.auth.AuthScope;
> import org.apache.http.auth.NTCredentials;
> import org.apache.http.impl.client.BasicCredentialsProvider;
> import org.apache.http.client.methods.HttpGet
> import org.apache.http.util.EntityUtils
> 
> credProv	= org.apache.http.impl.client.BasicCredentialsProvider()	# Build credentials provider
> ntCred = org.apache.http.auth.NTCredentials(un, pwd, '', do) # Build NT domain credentials
> credProv.setCredentials(org.apache.http.auth.AuthScope.ANY, ntCred);	# Set credentials
> bld = org.apache.http.impl.client.HttpClientBuilder.create()	# Create HttpClientBuilder
> client = bld.setDefaultCredentialsProvider(credProv).build() # Build client with credential proxy
> 
> get = org.apache.http.Client.methods.HttpGet(url)	# Define http get
> res = client.execute(get) # Execute get
> 
> # Result string
> ress = str(org.apache.http.util.EntityUtils.toString(res.getEntity(), 'UTF-8'))
> 
> ```

> **Slimmed**
>
> ```python
> from org.apache.http.auth import AuthScope, NTCredentials
> from org.apache.http.impl.client import BasicCredentialsProvider, HttpClientBuilder
> from org.apache.http.client.methods import HttpGet
> from org.apache.http.util import EntityUtils
> 
> url = 'MY URL'
> un = 'MY USERNAME'
> do = 'MY DOMAIN'
> pwd = 'MY PASSWORD'
> 
> credProv	= BasicCredentialsProvider() # Build credentials provider
> ntCred = NTCredentials(un, pwd, '', do)	# Build NT domain credentials
> credProv.setCredentials(AuthScope.ANY, ntCred);	# Set credentials
> 
> bld = HttpClientBuilder.create() # Create HttpClientBuilder
> client = bld.setDefaultCredentialsProvider(credProv).build()	# Build client with credential proxy
> 
> get = HttpGet(url) # Define http get
> res = client.execute(get)	# Execute get
> 
> # Result string
> ress = str(EntityUtils.toString(res.getEntity(), 'UTF-8'))
> 
> ```
