Call the Nodinite Web API with Windows Authentication
Section titled “ Call the Nodinite Web API with Windows Authentication”When Nodinite uses Windows Authentication, the Web API accepts the Windows identity of the caller (Kerberos or NTLM). A script that runs as a domain user or service account doesn't need a token: the HTTP client negotiates authentication with IIS, and Nodinite grants access based on the Windows account or its Windows AD Groups and their Roles.
Use this guide when your Nodinite environment runs in Windows Authentication mode. When it runs in OpenID Connect / OAuth 2.0 mode, use Call the Web API with OAuth 2.0 Client Credentials instead.
Understanding Windows Authentication
Section titled “ Understanding Windows Authentication”runs as a Windows account"] -->|Kerberos / NTLM| IIS["fa:fa-globe IIS"] IIS --> API["fa:fa-cloud-sun Web API"] API --> Access["fa:fa-user-shield User or Windows AD Group
mapped to a Role"] API --> DB["fa:fa-database Databases"]
The script runs as a Windows account. IIS authenticates it, and Nodinite maps the account, or a Windows AD Group it belongs to, to a Role.
Choose How the Script Authenticates
Section titled “ Choose How the Script Authenticates”| Approach | When to use | Examples below |
|---|---|---|
| Current Windows identity (integrated) | The script runs on a domain-joined Windows host as a user or service account. No password in the script. | PowerShell, Python (Windows), C# |
| Explicit credentials (NTLM) | The script runs on Linux, in a container, or as another account. Read the password from a secret store. | Python (Linux), Node.js |
Prerequisites
Section titled “ Prerequisites”- Nodinite runs in Windows Authentication mode, set for the environment in the Nodinite Portal (Auth step).
- The Windows account that runs the script is added as a User, or belongs to a Windows AD Group, with a suitable Role.
- You know the Web API base URL of your environment. The examples use
<webapi-base-url>, for examplehttps://nodinite.contoso.com:40001. The port is set for each environment in the Nodinite Portal (Servers step). To check it, add/scalarand open it in your browser. See Find the base URL.
Each example reads the Integrations in the Repository Model and prints the first Integration Id.
PowerShell
Section titled “ PowerShell”Use Invoke-RestMethod with -UseDefaultCredentials.

Animated walkthrough: PowerShell 7 runs as a Windows account on a server in the domain. The same search for the Contoso Integrations first runs without credentials and gets 401 with WWW-Authenticate: Negotiate. With -UseDefaultCredentials, the Windows identity signs in and the five Integrations come back as JSON.
$nodiniteWebApiUrl = "<webapi-base-url>/api"
$getResponse = Invoke-RestMethod -Uri "$nodiniteWebApiUrl/integrations" -Method Get -UseDefaultCredentials$getResponse.Collection.Items[0].Data.IntegrationIdExample: Retrieve the first Integration Id with the current Windows identity.
Python
Section titled “ Python”Python on Windows
Section titled “Python on Windows”requests-negotiate-sspi uses the Windows SSPI interface and the current Windows identity. Install the dependencies first: pip install requests requests-negotiate-sspi.
import requestsfrom requests_negotiate_sspi import HttpNegotiateAuth
url = "<webapi-base-url>/api/integrations"
# Uses the current Windows identity (Kerberos/NTLM negotiation)response = requests.get(url, auth=HttpNegotiateAuth(), timeout=30)response.raise_for_status()
print(response.json()["Collection"]["Items"][0]["Data"]["IntegrationId"])Example: Retrieve the first Integration Id with the current Windows identity.
Python on Linux
Section titled “Python on Linux”SSPI isn't available outside Windows, but NTLM works cross-platform with a username and password. Install the dependencies first: pip install requests requests-ntlm.
import osimport requestsfrom requests_ntlm import HttpNtlmAuth
url = "<webapi-base-url>/api/integrations"
# Read credentials from environment variables - never hardcode secretsusername = os.environ["NODINITE_USERNAME"] # e.g. "DOMAIN\\serviceaccount"password = os.environ["NODINITE_PASSWORD"]
response = requests.get(url, auth=HttpNtlmAuth(username, password), timeout=30)response.raise_for_status()
print(response.json()["Collection"]["Items"][0]["Data"]["IntegrationId"])Example: Retrieve the first Integration Id from a Linux host with NTLM.
HttpClientHandler with UseDefaultCredentials sends the current Windows identity.
using System.Text.Json;
using var handler = new HttpClientHandler { UseDefaultCredentials = true };using var http = new HttpClient(handler) { BaseAddress = new Uri("<webapi-base-url>/") };
var json = await http.GetStringAsync("api/integrations");using var doc = JsonDocument.Parse(json);
var firstIntegration = doc.RootElement .GetProperty("Collection").GetProperty("Items")[0] .GetProperty("Data").GetProperty("IntegrationId");Console.WriteLine(firstIntegration);Example: Retrieve the first Integration Id with the current Windows identity.
Node.js
Section titled “ Node.js”This example uses httpntlm. Run npm install httpntlm first.
const httpntlm = require('httpntlm');
httpntlm.get({ url: '<webapi-base-url>/api/integrations', username: process.env.NODINITE_USERNAME, password: process.env.NODINITE_PASSWORD, domain: process.env.NODINITE_DOMAIN}, (err, res) => { if (err) return console.error(err);
const jsonBody = JSON.parse(res.body); console.log(`First Integration Id: ${jsonBody.Collection.Items[0].Data.IntegrationId}`);});Example: Retrieve the first Integration Id with explicit Windows credentials.
Troubleshooting
Section titled “ Troubleshooting”| Symptom | Fix |
|---|---|
401 from the Web API |
First check that the call sends Windows credentials: -UseDefaultCredentials in PowerShell, UseDefaultCredentials = true in C#. A call without them gets 401 with WWW-Authenticate: Negotiate. Then check that the account is a domain account that IIS accepts, and that the host and URL match the SPN when you use Kerberos. See HTTP SPN for IIS. |
200 but empty results |
The account is authenticated but has no access to the data. Check its Roles. |
| Works interactively, fails as a scheduled task | The task runs as another account. Give that service account access in Nodinite. |