---
title: Call the Nodinite Web API with Windows Authentication
description: Call the Nodinite Web API from scripts and code when Nodinite uses Windows Authentication. Examples in PowerShell, Python (Windows and Linux), C#, and Node.js using the current Windows identity or a service account.
---

# :fab fa-windows: 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][OAuth 2.0] instead.

>[!TIP]
>The Web API is **deterministic** and ideal for scripts and pipelines. For natural-language questions about your integrations from VS Code or Claude Desktop, use the [MCP Endpoint][]. See [Web API or MCP Endpoint?][Web API or MCP Endpoint].

## :fa-diagram-project: Understanding Windows Authentication

<div class="mermaid">
graph LR
    Script["fa:fa-terminal Script or service<br/>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<br/>mapped to a Role"]
    API --> DB["fa:fa-database Databases"]
</div>

*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.*

### :fa-code-compare: 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 |

>[!TIP]
>Run scheduled scripts as a dedicated **service account**, and give it a [Role][Roles] with only the permissions it needs. Every change it makes is recorded in [Log Audits][] under that account.

## :fa-clipboard-check: Prerequisites

* :Nodinite: runs in Windows Authentication mode, set for the environment in the :Nodinite: Portal ([Auth step][Portal Auth Mode]).
* The Windows account that runs the script is added as a [User][Users], or belongs to a [Windows AD Group][Windows AD Groups], with a suitable [Role][Roles].
* You know the **Web API base URL** of your environment. The examples use `<webapi-base-url>`, for example `https://nodinite.contoso.com:40001`. The port is set for each environment in the :Nodinite: Portal ([Servers step][]). To check it, add `/scalar` and open it in your browser. See [Find the base URL][Base URL].

Each example reads the [Integrations][] in the [Repository Model][] and prints the first Integration Id.

## :fa-scroll: PowerShell

Use [Invoke-RestMethod](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod)<sup>:fa-arrow-up-right-from-square:</sup> with `-UseDefaultCredentials`.

![PowerShell 7 as a Windows account: a search for the Contoso Integrations, five per page; without credentials the Web API answers 401 with WWW-Authenticate Negotiate; with -UseDefaultCredentials the five Contoso Integrations come back as JSON, animated walkthrough (7.12)][1]  
*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.*  

```powershell
$nodiniteWebApiUrl = "<webapi-base-url>/api"

$getResponse = Invoke-RestMethod -Uri "$nodiniteWebApiUrl/integrations" -Method Get -UseDefaultCredentials
$getResponse.Collection.Items[0].Data.IntegrationId
```

*Example: Retrieve the first Integration Id with the current Windows identity.*

## :fab fa-python: Python

### 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`.

```python
import requests
from 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

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`.

```python
import os
import requests
from requests_ntlm import HttpNtlmAuth

url = "<webapi-base-url>/api/integrations"

# Read credentials from environment variables - never hardcode secrets
username = 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.*

>[!TIP]
>For pipelines on Linux or in containers, OAuth 2.0 **client credentials** avoids Windows passwords altogether, if your environment runs in OAuth mode. See [Call the Web API with OAuth 2.0 Client Credentials][OAuth 2.0].

## :fa-code: C\#

`HttpClientHandler` with `UseDefaultCredentials` sends the current Windows identity.

```csharp
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.*

## :fab fa-node-js: Node.js

This example uses [httpntlm](https://www.npmjs.com/package/httpntlm)<sup>:fa-arrow-up-right-from-square:</sup>. Run `npm install httpntlm` first.

```javascript
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.*

>[!IMPORTANT]
>Read passwords from environment variables or a secret store, never from source code. For extra protection, use the [Pre-Encrypt password](https://www.npmjs.com/package/httpntlm#pre-encrypt-the-password)<sup>:fa-arrow-up-right-from-square:</sup> feature.

## :fa-stethoscope: 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][HTTP SPN for IIS] 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:. |

## :fa-hand-point-right: Next Steps

* :fa-screwdriver: [Manage the Web API][]  
* :fa-list-ul: [Web API Scenarios][Scenarios]  
* :fa-user-shield: [Roles][]  

## :fa-link-horizontal: Related Topics

* :fa-key: [Call the Web API with OAuth 2.0 Client Credentials][OAuth 2.0]  
* :fa-users: [Windows AD Groups][]  
* :fa-plug: [MCP Endpoint][]  
* :fa-robot: [AI in Nodinite][AI]  
* :fa-scroll: [Log Audits][]  

[1]:{ndm}/Documentation%20Pictures/IM/CoreServices/WebAPI/WebAPI_WindowsAuth_PowerShell.gif

[AI]:{ndr}/AI/Overview.md
[Base URL]:{ndr}/Core%20Services/Web%20API/Features/Managing%20the%20Web%20API.md#find-the-base-url
[HTTP SPN for IIS]:{ndr}/Install%20and%20Update/Troubleshooting/IIS/HTTP%20SPN%20for%20IIS.md
[IIS]:{ndr}/Install%20and%20Update/Troubleshooting/IIS/IIS%20Authentication%20settings.md
[Integrations]:{ndr}/Repository%20Model/Integrations/Overview.md
[Log Audits]:{ndr}/Administration/6.%20Tools/2.%20Log%20Audit%20Search.md
[Manage the Web API]:{ndr}/Core%20Services/Web%20API/Features/Managing%20the%20Web%20API.md
[MCP Endpoint]:{ndr}/AI/MCP%20Endpoint.md
[OAuth 2.0]:{ndr}/Core%20Services/Web%20API/Scenarios/Call%20the%20Web%20API%20with%20OAuth%202.0%20Client%20Credentials.md
[Portal Auth Mode]:{ndr}/Install%20and%20Update/Getting%20started/Version%207/Install%20Nodinite%20v7%20Steps/02%20-%20Auth.md#auth-mode
[Repository Model]:{ndr}/Repository%20Model/Overview.md
[Roles]:{ndr}/Administration/3.%20Access%20Management/1.%20Roles/Features/Add%20or%20manage%20Role.md
[Scenarios]:{ndr}/Core%20Services/Web%20API/Scenarios/Overview.md
[Servers step]:{ndr}/Install%20and%20Update/Getting%20started/Version%207/Install%20Nodinite%20v7%20Steps/04%20-%20Servers.md#core-platform-services
[Users]:{ndr}/Administration/3.%20Access%20Management/2.%20Users/Features/Add%20or%20manage%20User.md
[Web API]:{ndr}/Core%20Services/Web%20API/Overview.md
[Web API or MCP Endpoint]:{ndr}/Core%20Services/Web%20API/Features/Managing%20the%20Web%20API.md#web-api-or-mcp-endpoint
[Windows AD Groups]:{ndr}/Administration/3.%20Access%20Management/3.%20Windows%20AD%20Groups/Features/Add%20or%20manage%20Windows%20AD%20Group.md