You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/agent-id/autonomous-agent-authentication-authorization-flow.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,12 @@ title: Authenticate and acquire tokens for autonomous agents
3
3
description: Learn how to authenticate autonomous agents with Microsoft Entra ID, grant application permissions, and optionally create and authenticate as an agent's user account.
4
4
titleSuffix: Microsoft Entra Agent ID
5
5
ms.topic: how-to
6
-
ms.date: 03/30/2026
6
+
ms.date: 06/15/2026
7
7
ms.reviewer: jomondi, dastrock
8
8
9
9
#customer-intent: As a developer building autonomous agents, I want to authenticate my agent, grant it application permissions, and optionally create an agent's user account, so that my agent can operate independently and access Microsoft Graph and other resources.
10
+
ai-usage: ai-assisted
11
+
ms.custom: msecd-doc-authoring-1013
10
12
---
11
13
12
14
# Authenticate and acquire tokens for autonomous agents
@@ -55,7 +57,7 @@ Gather the credential you configured on your agent identity blueprint. You need
For production, use a managed identity as a federated identity credential:
60
+
Configure *Microsoft.Identity.Web* to authenticate your agent identity blueprint using a federated identity credential. For production, use a managed identity as the federated identity credential:
59
61
60
62
```json
61
63
{
@@ -101,6 +103,8 @@ When using a client secret during local development, provide the `client_secret`
Use the following token request to obtain a token for the agent identity blueprint:
107
+
104
108
```http
105
109
POST https://login.microsoftonline.com/<my-test-tenant>/oauth2/v2.0/token
106
110
Content-Type: application/x-www-form-urlencoded
@@ -197,15 +201,15 @@ There are two ways to grant application permissions to an autonomous agent:
197
201
198
202
Use the following steps to get an app role assignment.
199
203
200
-
1.[Obtain an access token](#request-an-agent-identity-token) with the application permissions `Application.Read.All` and `AppRoleAssignment.ReadWrite.All`.
204
+
1.[Request an agent identity token](#request-an-agent-identity-token) with the application permissions `Application.Read.All` and `AppRoleAssignment.ReadWrite.All`.
201
205
202
206
1. Get the object ID of the resource service principal that you're trying to access. For example, to find the Microsoft Graph service principal object ID:
203
207
1. Go to the [Microsoft Entra admin center](https://entra.microsoft.com/).
204
208
1. Navigate to **Entra ID** --> **Enterprise Applications**
205
209
1. Filter by Application type == Microsoft Applications
206
210
1. Search for **Microsoft Graph**.
207
211
208
-
1. Get the unique ID of the [app role you want to assign](/graph/permissions-reference).
212
+
1. Get the unique ID of the app role you want to assign from the [Microsoft Graph permissions reference](/graph/permissions-reference).
209
213
210
214
1. Create the app role assignment:
211
215
@@ -267,7 +271,7 @@ Agent implementations might redirect the admin to this URL in various ways, such
267
271
> [!NOTE]
268
272
> Configure a redirect URI on your blueprint and include a `state` parameter in the consent request. When consent is granted, the user is sent to the redirect URI where you can display confirmation. Your endpoint can use the `state` parameter to track that permission was granted. For single-tenant agents, you can alternatively retry token requests until consent is granted because the tenant ID is already known.
269
273
270
-
After you grant your application the required permissions, request a new agent access token for the permissions to take effect.
274
+
After you grant your agent identity blueprint the required permissions, request a new agent access token for the permissions to take effect.
271
275
272
276
## Authenticate as an agent's user account
273
277
@@ -279,14 +283,14 @@ Each agent identity can only have a single associated agent's user account, and
279
283
280
284
To create agents' user accounts, your agent identity blueprint must be granted the application permission `AgentIdUser.ReadWrite.IdentityParentedBy` in the tenant. You can obtain authorization in one of two ways:
281
285
282
-
-[Request agent authorization](#request-authorization-from-a-tenant-administrator). Be sure to use your agent identity blueprint as the `client_id`, not the agent identity.
283
-
-[Manually create an appRoleAssignment](#create-an-app-role-assignment-via-apis) in the tenant. Use the service principal object ID of the agent identity blueprint as the `principalId` value, not its application (client) ID.
286
+
-[Request authorization from a tenant administrator](#request-authorization-from-a-tenant-administrator). Be sure to use your agent identity blueprint as the `client_id`, not the agent identity.
287
+
-[Create an app role assignment via APIs](#create-an-app-role-assignment-via-apis) in the tenant. Use the service principal object ID of the agent identity blueprint as the `principalId` value, not its application (client) ID.
284
288
285
289
If you wish to use a different client, not the agent identity blueprint, to create agents' user accounts, that client needs to obtain the `AgentIdUser.ReadWrite.All` delegated or application permission instead.
286
290
287
291
### Create an agent's user account
288
292
289
-
Create an agent's user account using your agent identity blueprint or other approved client. The recommended way to create an agent's user account is using your agent identity blueprint. You [require an access token](create-delete-agent-identities.md#get-an-access-token-using-agent-identity-blueprint) to create an agent's user account.
293
+
Create an agent's user account using your agent identity blueprint or other approved client. The recommended way to create an agent's user account is using your agent identity blueprint. You need to [get an access token using the agent identity blueprint](create-delete-agent-identities.md#get-an-access-token-using-agent-identity-blueprint) to create an agent's user account.
290
294
291
295
#### [REST](#tab/rest)
292
296
@@ -409,7 +413,7 @@ Once you have your agent's user account created, you don't need to configure any
409
413
410
414
### Grant consent to agent identity
411
415
412
-
Agents' user accounts behave like any other user account. Before you can request tokens using your agent's user account, you need to authorize the agent identity to act on its behalf. You can authorize the agent identity using [admin authorization](#request-authorization-from-a-tenant-administrator) or manually create an `oAuth2PermissionGrant` using Microsoft Graph or Microsoft Graph PowerShell.
416
+
Agents' user accounts behave like any other user account. Before you can request tokens using your agent's user account, you need to authorize the agent identity to act on its behalf. You can authorize the agent identity by [requesting authorization from a tenant administrator](#request-authorization-from-a-tenant-administrator) or manually create an `oAuth2PermissionGrant` using Microsoft Graph or Microsoft Graph PowerShell.
413
417
414
418
For Microsoft Graph, your request is as shown in the following snippet:
415
419
@@ -458,7 +462,7 @@ To authenticate an agent's user account, you need to follow a three-step process
458
462
459
463
#### [REST](#tab/rest)
460
464
461
-
First, request a token as the agent identity blueprint, as described in [Request a token for the agent identity blueprint](#request-a-token-for-the-agent-identity-blueprint). Once you have your agent app token, use it to request a Federated Identity Credential (FIC) for your agent identity:
465
+
First, request a token as the agent identity blueprint, as described in [Request a token for the agent identity blueprint](#request-a-token-for-the-agent-identity-blueprint). Once you have the agent identity blueprint token, use the agent identity blueprint token to request a Federated Identity Credential (FIC) for your agent identity:
462
466
463
467
```http
464
468
POST https://login.microsoftonline.com/<my-test-tenant>/oauth2/v2.0/token
Copy file name to clipboardExpand all lines: docs/agent-id/integrate-n8n-agent.md
+19-11Lines changed: 19 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,12 @@ titleSuffix: Microsoft Entra Agent ID
4
4
description: Deploy n8n on Azure Container Apps and secure AI agent workflows with Microsoft Entra Agent ID and Microsoft Graph MCP Server for Enterprise.
5
5
ms.service: entra
6
6
ms.topic: how-to
7
-
ms.date: 04/30/2026
7
+
ms.date: 06/15/2026
8
+
author: Dickson-Mwendia
9
+
ms.author: dmwendia
8
10
ms.reviewer: astaykov
9
-
ms.custom: agent-id, msecd-doc-authoring-1012
11
+
ms.custom: agent-id, msecd-doc-authoring-1013
12
+
ai-usage: ai-assisted
10
13
11
14
#customer intent: As a developer or IT admin, I want to secure n8n workflows with Microsoft Entra Agent ID so that my n8n agents can access Microsoft Graph and MCP Server for Enterprise using agent identities.
This guide shows how to deploy [n8n](https://n8n.io/) on Azure Container Apps with Microsoft Entra Agent ID integration. The deployment uses the Azure Developer CLI (`azd`) to provision infrastructure, create Microsoft Entra identity objects, and configure n8n workflows automatically.
18
21
19
-
Unlike the [sidecar pattern](authentication-with-auth-sdk-sidecar.md) used for custom agents, this integration uses the [n8n-nodes-entraagentid](https://www.npmjs.com/package/@astaykov/n8n-nodes-entraagentid) community node to manage token acquisition directly within n8n workflows. The deployed workflows demonstrate both autonomous (app-only) and on-behalf-of (OBO) token flows, with access to Microsoft Graph and the Microsoft Graph MCP Server for Enterprise, `https://mcp.svc.cloud.microsoft/enterprise`.
22
+
Unlike the [Authentication with Microsoft Entra Auth SDK sidecar](authentication-with-auth-sdk-sidecar.md)pattern used for custom agents, the n8n integration uses the [n8n-nodes-entraagentid](https://www.npmjs.com/package/@astaykov/n8n-nodes-entraagentid) community node to manage token acquisition directly within n8n workflows. The deployed workflows demonstrate both autonomous (app-only) and on-behalf-of (OBO) token flows, with access to Microsoft Graph and the Microsoft Graph MCP Server for Enterprise, `https://mcp.svc.cloud.microsoft/enterprise`.
20
23
21
24
> [!NOTE]
22
25
> This sample demonstrates the use of the `n8n-nodes-entraagentid` community node within n8n. It isn't guidance for deploying n8n on Azure in production.
@@ -38,7 +41,7 @@ If you're running locally instead of Cloud Shell, install these tools before pro
38
41
-[Microsoft.Entra PowerShell module](/powershell/entra-powershell/) v1.2 or later.
39
42
- Git.
40
43
41
-
Sign in to Azure CLI and Azure Developer CLI before running the deployment:
44
+
Authenticate both the Azure CLI and Azure Developer CLI so that the deployment commands can create and manage resources in your subscription:
42
45
43
46
```bash
44
47
az login
@@ -67,7 +70,7 @@ The entire deployment runs through a single `azd up` command that provisions Azu
67
70
-**n8n admin email:** Email for the n8n owner account.
68
71
-**n8n admin password:** Password for the n8n owner account (minimum 8 characters, mixed case, number).
69
72
70
-
1. During the postprovision phase, the automation performs a second sign-in. A device code is displayed. Open the URL and enter the code. This step requires the Global Administrator or Application Administrator role. The postprovision hook then:
73
+
1. During the postprovision phase, the automation performs a second sign-in. A device code is displayed. Open the URL and enter the code. This step requires the Global Administrator or Application Administrator role. The `azd up`postprovision hook then:
71
74
72
75
- Creates Microsoft Entra Agent ID objects (Blueprint, Agent Identity, Agent User).
73
76
- Enables the Microsoft Graph MCP Server for Enterprise.
@@ -82,7 +85,10 @@ When the deployment completes, the script prints your n8n URL and a summary of w
82
85
83
86
## Explore the deployed resources
84
87
85
-
### Azure infrastructure
88
+
The deployment creates Azure resources, Microsoft Entra identity objects, and n8n configuration assets that work together to support the sample workflows.
89
+
90
+
<aname="azure-infrastructure"></a>
91
+
### Review the Azure infrastructure resources
86
92
87
93
The deployment creates the following Azure resources:
88
94
@@ -94,7 +100,8 @@ The deployment creates the following Azure resources:
94
100
-**Azure OpenAI:** GPT model deployment used by the AI agent workflows.
95
101
-**Log Analytics Workspace:** Diagnostics and monitoring.
96
102
97
-
### Microsoft Entra identity objects
103
+
<aname="microsoft-entra-identity-objects"></a>
104
+
### Review the Microsoft Entra identity objects
98
105
99
106
The automation creates these objects once and reuses them on subsequent runs:
100
107
@@ -103,7 +110,8 @@ The automation creates these objects once and reuses them on subsequent runs:
103
110
-**Agent user account:** A cloud-only user identity that enables delegated (OBO) token flows.
104
111
-**Single page app (SPA) app registration:** Client app for the webhook demo, preconfigured with redirect URIs and Blueprint API permissions.
105
112
106
-
### n8n credentials and workflows
113
+
<aname="n8n-credentials-and-workflows"></a>
114
+
### Review the n8n credentials and workflows
107
115
108
116
The postprovision hook automatically configures n8n:
109
117
@@ -129,7 +137,7 @@ The n8n deployment supports two token flow patterns:
129
137
130
138
-**On-behalf-of (OBO) with MCP:** A browser-based SPA sends a bearer token to an n8n webhook. The webhook calls the Auth Manager workflow, which uses the Blueprint credentials to acquire a delegated token on behalf of the Agent User. The Auth Manager forwards the token to a subworkflow that calls the Microsoft Graph MCP Server for Enterprise, which translates MCP tool calls into Microsoft Graph API requests using the delegated token.
131
139
132
-
In both patterns, the Agent Identity Blueprint acts as a token factory. It issues tokens for Agent Identities without storing credentials on the agent itself. The Auth Manager community node handles token acquisition and AES-256-GCM caching within each workflow run.
140
+
In both patterns, the Agent Identity Blueprint acts as a token factory. The Agent Identity Blueprint issues tokens for Agent Identities without storing credentials on the agent itself. The Auth Manager community node handles token acquisition and AES-256-GCM caching within each workflow run.
133
141
134
142
## Deploy the test SPA (optional)
135
143
@@ -169,7 +177,7 @@ The deployment is fully idempotent:
169
177
- The `azd` environment saves Microsoft Entra object IDs (Blueprint, Agent Identity, Agent User, Blueprint secret) after the first run and reuses them on subsequent runs.
170
178
- n8n configuration (credentials, workflows) is applied fresh each run, which allows repairing a broken state.
171
179
172
-
To rerun just the postprovision scripts without modifying infrastructure:
180
+
To rerun just the postprovision scripts without modifying infrastructure, run provisioning again. The Bicep templates detect no infrastructure changes and only execute the deployment hooks:
173
181
174
182
```bash
175
183
azd provision # Bicep detects no changes, runs hooks only
@@ -206,7 +214,7 @@ You can run the configuration scripts independently if needed:
206
214
207
215
## Clean up resources
208
216
209
-
Remove all Azure resources that the deployment created:
217
+
Remove all Azure resources that the deployment created and purge any retained deployment state:
Copy file name to clipboardExpand all lines: docs/agent-id/interactive-agent-authentication-authorization-flow.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,12 @@ titleSuffix: Microsoft Entra Agent ID
5
5
6
6
7
7
ms.topic: how-to
8
-
ms.date: 06/03/2026
8
+
ms.date: 06/15/2026
9
9
ms.reviewer: dastrock, jomondi
10
10
ai-usage: ai-assisted
11
11
12
12
#customer-intent: As a developer building interactive agents, I want to authenticate users, configure authorization, and acquire tokens through the On-Behalf-Of flow, so that my agent can securely act on behalf of users to access protected resources.
13
+
ms.custom: msecd-doc-authoring-1013
13
14
---
14
15
15
16
# Authenticate users and acquire tokens for interactive agents
0 commit comments