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

# <i class="fab fa-windows" aria-hidden="true"></i> Call the Nodinite Web API with Windows Authentication

When <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> 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 <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> grants access based on the Windows account or its [Windows AD Groups][] and their [Roles][].

Use this guide when your <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> 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.

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>The Web API is <strong>deterministic</strong> and ideal for scripts and pipelines. For natural-language questions about your integrations from VS Code or Claude Desktop, use the <a href="https://docs.nodinite.com/ai/mcp-endpoint/">MCP Endpoint</a>. See <a href="https://docs.nodinite.com/core-services/web-api/features/managing-the-web-api/#web-api-or-mcp-endpoint">Web API or MCP Endpoint?</a>.</p></div>
</aside>

## <i class="fal fa-diagram-project" aria-hidden="true"></i> 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 <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> maps the account, or a Windows AD Group it belongs to, to a Role.*

### <i class="fal fa-code-compare" aria-hidden="true"></i> 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 |

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>Run scheduled scripts as a dedicated <strong>service account</strong>, and give it a <a href="https://docs.nodinite.com/administration/access-management/roles/features/add-or-manage-role/">Role</a> with only the permissions it needs. Every change it makes is recorded in <a href="https://docs.nodinite.com/administration/tools/log-audit-search/">Log Audits</a> under that account.</p></div>
</aside>

## <i class="fal fa-clipboard-check" aria-hidden="true"></i> Prerequisites

* <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> runs in Windows Authentication mode, set for the environment in the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> 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 <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> 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.

## <i class="fal fa-scroll" aria-hidden="true"></i> PowerShell

Use [Invoke-RestMethod](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></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.*

## <i class="fab fa-python" aria-hidden="true"></i> 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.*

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>For pipelines on Linux or in containers, OAuth 2.0 <strong>client credentials</strong> avoids Windows passwords altogether, if your environment runs in OAuth mode. See <a href="https://docs.nodinite.com/core-services/web-api/scenarios/call-the-web-api-with-oauth-2-0-client-credentials/">Call the Web API with OAuth 2.0 Client Credentials</a>.</p></div>
</aside>

## <i class="fal fa-code" aria-hidden="true"></i> 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.*

## <i class="fab fa-node-js" aria-hidden="true"></i> Node.js

This example uses [httpntlm](https://www.npmjs.com/package/httpntlm)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></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.*

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p>Read passwords from environment variables or a secret store, never from source code. For extra protection, use the <a href="https://www.npmjs.com/package/httpntlm#pre-encrypt-the-password">Pre-Encrypt password</a><sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup> feature.</p></div>
</aside>

## <i class="fal fa-stethoscope" aria-hidden="true"></i> 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 <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>. |

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-screwdriver" aria-hidden="true"></i> [Manage the Web API][]  
* <i class="fal fa-list-ul" aria-hidden="true"></i> [Web API Scenarios][Scenarios]  
* <i class="fal fa-user-shield" aria-hidden="true"></i> [Roles][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-key" aria-hidden="true"></i> [Call the Web API with OAuth 2.0 Client Credentials][OAuth 2.0]  
* <i class="fal fa-users" aria-hidden="true"></i> [Windows AD Groups][]  
* <i class="fal fa-plug" aria-hidden="true"></i> [MCP Endpoint][]  
* <i class="fal fa-robot" aria-hidden="true"></i> [AI in Nodinite][AI]  
* <i class="fal fa-scroll" aria-hidden="true"></i> [Log Audits][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/CoreServices/WebAPI/WebAPI_WindowsAuth_PowerShell.gif

[AI]:https://docs.nodinite.com/ai/overview/
[Base URL]:https://docs.nodinite.com/core-services/web-api/features/managing-the-web-api/#find-the-base-url
[HTTP SPN for IIS]:https://docs.nodinite.com/install-and-update/troubleshooting/iis/http-spn-for-iis/
[IIS]:https://docs.nodinite.com/install-and-update/troubleshooting/iis/iis-authentication-settings/
[Integrations]:https://docs.nodinite.com/repository-model/integrations/overview/
[Log Audits]:https://docs.nodinite.com/administration/tools/log-audit-search/
[Manage the Web API]:https://docs.nodinite.com/core-services/web-api/features/managing-the-web-api/
[MCP Endpoint]:https://docs.nodinite.com/ai/mcp-endpoint/
[OAuth 2.0]:https://docs.nodinite.com/core-services/web-api/scenarios/call-the-web-api-with-oauth-2-0-client-credentials/
[Portal Auth Mode]:https://docs.nodinite.com/install-and-update/getting-started/version-7/install-nodinite-v7-steps/02-auth/#auth-mode
[Repository Model]:https://docs.nodinite.com/repository-model/overview/
[Roles]:https://docs.nodinite.com/administration/access-management/roles/features/add-or-manage-role/
[Scenarios]:https://docs.nodinite.com/core-services/web-api/scenarios/overview/
[Servers step]:https://docs.nodinite.com/install-and-update/getting-started/version-7/install-nodinite-v7-steps/04-servers/#core-platform-services
[Users]:https://docs.nodinite.com/administration/access-management/users/features/add-or-manage-user/
[Web API]:https://docs.nodinite.com/core-services/web-api/overview/
[Web API or MCP Endpoint]:https://docs.nodinite.com/core-services/web-api/features/managing-the-web-api/#web-api-or-mcp-endpoint
[Windows AD Groups]:https://docs.nodinite.com/administration/access-management/windows-ad-groups/features/add-or-manage-windows-ad-group/