# Configure Human Approval with Microsoft Entra ID

Set up human approval for a gateway that signs users in through Microsoft Entra ID.

## Overview

This guide sets up human approval for gateways that sign users in with Microsoft Entra ID. You'll register an approval application in your Entra tenant and add its client ID to your gateway configuration.

Before you start, your gateway must already use Entra as its identity provider. See [Configure Microsoft Entra ID](/docs/identity-provider-entra).

## Register the approval application in Entra

Register a new application in the **same tenant** that signs users in to your gateway. Don't reuse the gateway application or an AI client's application.

1. In the <a href="https://entra.microsoft.com" target="_blank" rel="noopener noreferrer">Microsoft Entra admin center</a>, go to **App registrations → New registration**.
   - **Name**: for example `Dtwo Human Approval`. People see this name on the Microsoft sign-in screen when they approve a request, so pick one they'll recognize.
   - **Supported account types**: **Single Tenant Only — Default Directory**.
   - Leave **Redirect URI** empty and select **Register**.
2. From the app's **Overview** page, copy the **Application (client) ID**. Then go to **Vault** in the Dtwo UI, select **Add entry**, and fill in:
   - **Name**: `ENTRA_APPROVAL_CLIENT_ID`
   - **Value**: the **Application (client) ID** you copied
   - **Used by**: **All gateways**, so every gateway in this Entra tenant can use the same approval application. Choose a single gateway instead if only one gateway needs it.

   The client ID isn't a secret, so you don't need to turn on **Encrypted value**.



3. Go to **Authentication**, on the **Redirect URI configuration** tab select **Add Redirect URI**, and then select **Mobile and desktop applications**. Copy the **Approval callback URL** from your gateway's **Overview** tab in the Dtwo UI, add it as a custom redirect URI, and select **Configure**.

4. Go to **Token configuration → Add optional claim**, choose **ID**, check **`auth_time`** and **`email`**, and select **Add**. Accept the prompt to add the Microsoft Graph `email` and `profile` permissions.

5. Go to **API permissions** and select **Grant admin consent for** your tenant, then confirm. This approves the sign-in permissions for everyone in your tenant, so your end users never see a consent screen when they approve an action.

One approval application can serve several gateways in the same tenant. Add each gateway's approval callback URL to its redirect list exactly as written — don't use wildcards.

## Configure your Dtwo gateway

Go to your gateway in the Dtwo UI and open **Configuration → Advanced**. In the `gateway` section, add a `session_control` entry next to your existing `authentication` entry:

```yaml
session_control:
  client_id: <<ENTRA_APPROVAL_CLIENT_ID>>
  redirect_uri: "<ApprovalCallbackURL>"
  clearing:
    enabled: true
```

`<<ENTRA_APPROVAL_CLIENT_ID>>` pulls the client ID from the Vault entry you added in step 2. If you named the entry something else, use that name instead.

Replace `<ApprovalCallbackURL>` with the **Approval callback URL** from your gateway's **Overview** tab, the same URL you added in step 3.

## Test an approval

In your AI client, ask the agent to do something that needs approval. For example, invoke a policy that enables a dynamic safeguard and ask to disable the safeguard. The agent returns a link.

Open the link. Microsoft asks you to sign in again even if you're already signed in — that's expected. Sign in as the same user your AI client is signed in as, then approve the action.

---

Having trouble? Email [support@dtwo.ai](mailto:support@dtwo.ai).