# Migrate Entra to v2.0 Access Tokens

Move a Dtwo gateway set up with Entra v1.0 access tokens to v2.0 access tokens.

## Overview

Earlier versions of the Entra setup guide set gateways up to accept Entra v1.0 access tokens. You can tell such a gateway by its `jwt_issuer`, which starts with `https://sts.windows.net/`. These gateways keep working, but Claude Cowork can only connect to them with a client secret.

Migrating to the configuration in [Configure Microsoft Entra ID](/docs/identity-provider-entra) changes the issuer of every access token the gateway accepts. Check the two effects below before you start.

## Effect on active safeguards

Dynamic safeguards are tied to the token issuer. Once the gateway accepts v2.0 tokens, safeguards set before the migration no longer apply, and tool calls they were blocking go through. If a safeguard needs to stay in place, set it again after the migration, for example by repeating the action that triggered it.


## Effect on human approval

This applies only if your gateway configuration has a `session_control` entry (see [Configure Human Approval with Microsoft Entra ID](/docs/human-approval-entra)).

With v1.0 tokens, the gateway works out the approval callback from its audience, which is the gateway URL, so `session_control` can leave out `redirect_uri`. After the migration, the audience is `<ApplicationId>` and the gateway can no longer work out the callback. Set `redirect_uri` to the **Approval callback URL** shown on your gateway's **Overview** tab. It has the form `https://<gateway-host>/session-control/clear/callback`.

## Migration steps

1. Pick a quiet time. Claude Code and Cursor reconnect on their own within seconds; other clients may take longer or need users to reconnect.
2. If any of your policies read the `upn` or `email` claim, add the [optional upn claim](/docs/identity-provider-entra#optional-add-the-upn-claim) to the gateway application.
3. Prepare the gateway configuration from [Configure your Dtwo gateway](/docs/identity-provider-entra#configure-your-dtwo-gateway). If your current configuration has a `session_control` entry, keep it and add `redirect_uri` as described in [Effect on human approval](#effect-on-human-approval).
4. In the gateway application's manifest, set `accessTokenAcceptedVersion` to `2` (see step 5 of [Register the gateway application in Entra](/docs/identity-provider-entra#register-the-gateway-application-in-entra)). Deploy the new gateway configuration right away. Until you do, any client that renews its token gets a v2.0 token, which the old configuration rejects.
5. Reset any safeguards that need to stay in place.

## Remove the client secret from an existing Claude Cowork setup

Earlier versions of the Entra setup guide registered Claude Cowork under **Web** with a client secret. Client secrets expire, and
Claude Cowork stops connecting when its secret is no longer valid.

Claude Cowork can only connect without a secret if the gateway is set up to use the v2.0 access token. If your gateway's `jwt_issuer` still starts with `https://sts.windows.net/`, keep the secret and [migrate the gateway](#migration-steps) first.

To remove the client secret:

1. In the Claude Cowork app registration, go to **Authentication**. Remove `https://claude.ai/api/mcp/auth_callback` from **Web** and add it under **Mobile and desktop applications**. Leave **Allow public client flows** set to **No**.
2. Wait a few minutes for Entra to apply the change.
3. In Claude Desktop, clear **OAuth Client Secret** on the connector, and on the organization connector if you have one. Then reconnect.
4. When every connector signs in without the secret, delete the secret under **Certificates & secrets**.

If you skip step 3, the connector fails with error code `AADSTS700025`.

## Verify your gateway's custom domain

This step is needed only if Entra refuses your gateway's URL when you add it to `identifierUris`. For a gateway hosted by Dtwo, verifying the domain is a two-party handshake, because Dtwo owns the `dtwo.ai` DNS zone:

1. In the Entra admin center, go to **Domain names → Add custom domain**, enter your gateway's domain (for example `<customer>.hosted.us1.prod.dtwo.ai`), and select **Add domain**. Entra responds with a TXT record value in the form `MS=ms########`.
2. Email that `MS=ms########` value to [support@dtwo.ai](mailto:support@dtwo.ai). Dtwo adds the TXT record to DNS and replies once it's live.
3. Return to the **Add custom domain** screen for that domain and select **Verify**.

## Troubleshooting

| Error code      | What to do                                                                                                                                                     |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AADSTS7000218` | Entra expects a client secret. Move the client's redirect URI from **Web** to **Mobile and desktop applications**, wait a few minutes, and connect again.      |
| `AADSTS700025`  | The client still sends a client secret. Clear the secret in the client's settings and connect again.                                                           |
| `AADSTS50011`   | The redirect URI isn't registered. Add the URI shown in the error to the client's app registration under **Mobile and desktop applications**.                  |
| `AADSTS500011`  | Entra can't find the gateway application. Check that your gateway's URL is in `identifierUris`, and that `sso_generic_scope` ends in `<GatewayURL>/mcp`.       |
| `AADSTS9010010` | The gateway asks for scopes that don't belong to the gateway application. Check that `sso_generic_scope` ends in `<GatewayURL>/mcp`, and redeploy the gateway. |
| `AADSTS700016`  | The client ID isn't registered in this tenant. Check that the client uses the `<ClientId>` from its own app registration.                                      |

---

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