Skip to main content

Entra SSO for Copilot Cowork

Microsoft Copilot Cowork can reach your AI Gateway's MCP endpoint and call your governed tools. Each request carries the signed-in user's Microsoft Entra token. LangGuard validates that token against your directory, then forwards the call to your tools under a key scoped to your workspace, so every Cowork tool call is evaluated by policy before it runs.

Whether a policy verdict can block the call depends on the Enforcement Mode. In Shadow mode, the default, LangGuard records what Enforce mode would block, and the call runs.

Navigation: Settings → AI Gateway → Microsoft Entra SSO (Copilot Cowork) (/settings/ai-gateway)

Private installs

The URLs on this page are for LangGuard cloud. On a private install, replace https://<tenant>.app.langguard.ai and https://app.langguard.ai with https://<domain>. Copilot Cowork connects to the MCP endpoint from the Microsoft cloud, so the install needs a public ingress. See Set up the AI gateway.

The settings page carries a five-step walkthrough that prints the exact value for every field, with copy buttons. This page is the same procedure in reference form, plus the failure modes and what the gateway checks on each token.

How it works​

Copilot Cowork (user signs in with their Entra account)
│ MCP call + Entra access token
▼
https://<tenant>.app.langguard.ai/aigateway/mcp
│ 1. verify the signature against your directory's JWKS
│ 2. check the issuer is your directory, and the audience is one you accept
│ 3. check the requesting client (azp) is the gateway app
▼
LangGuard policy evaluation, then your governed MCP tools

The connection is made by a plugin package — a Teams app .zip that LangGuard generates for you. It contains a manifest pointing at your gateway's MCP URL and an OAuth reference derived from your directory id and Application ID URI.

Before you start​

You needFor
Application Administrator in your Entra directory (Global Administrator or Cloud Application Administrator also work)Registering the app and creating its client secret. Without it, Entra hides or rejects both.
Node.js, to run npxStep 5 installs the plugin from your own machine with the Microsoft 365 Agents Toolkit CLI. You sign in with the CLI before you install.
Teams Administrator, or Global AdministratorOnly to publish the plugin to everyone (--scope Organization). Installing it for yourself (--scope Personal) needs no further role.
Two portals, and they interleave twice

This spans the Entra admin center and the Teams Developer Portal, and the order is forced by a circular dependency: the Application ID URI in Entra embeds an id that the Teams portal only issues after you save the OAuth client, and that client's Scope names a permission that does not exist until Entra has the URI. So you visit Entra, then Teams, then Entra, then Teams again. Follow the steps in order and each value exists by the time you need it.

The values you collect​

ValueWhere you get itWhere you use it
Application (client) IDEntra app → Overview → EssentialsTeams OAuth client, the Application ID URI, accepted audiences
Directory (tenant) IDEntra app → Overview → EssentialsTeams endpoints, and the form in LangGuard
Client secret valueEntra app → Certificates & secretsTeams OAuth client
OAuth client registration IDTeams portal, after you save the OAuth clientDecodes to the auth-config id, which the Application ID URI needs
Application ID URIYou compose it: api://auth-<auth-config-id>/<client-id>Entra Expose an API, the Teams Scope, accepted audiences

The walkthrough in the app has a scratchpad at the top. Paste the client id, the directory id and the registration id into it as you collect them, and every later value is printed in full with a copy button instead of a placeholder.

Step 1 — Create the Entra app​

Entra admin center → Entra ID → App registrations

If a gateway app already exists for this directory, reuse it. Check the All applications tab first. A second app changes the Application ID URI, and the plugin is keyed to it, so a duplicate breaks the connector silently.

a. Register the app​

FieldValue
NameAnything, for example LangGuard MCP gateway
Account typesSingle tenant (this organizational directory) only
Redirect URILeave empty. You set it in step 3.

From Overview → Essentials, copy the Application (client) ID and the Directory (tenant) ID.

b. Add a client secret​

The new app → Manage → Certificates & secrets → New client secret

FieldValue
DescriptionAnything, for example LangGuard gateway
ExpiresThe shortest period you can rotate. Note the date.
ValueCopy it now. Entra shows the secret value once, on that screen only.

Copy the Value column, not the Secret ID. The Secret ID is not a credential. The connector stops on the day the secret lapses, so rotate it before then.

Step 2 — Register the OAuth client​

Teams Developer Portal → Tools → OAuth client registration → Register client

a. App settings​

FieldValue
Registration nameAnything
Base URLYour LangGuard URL, for example https://app.langguard.ai
Restrict usage by organizationMy organization only
Restrict usage by Teams appAny Teams app

b. OAuth settings​

FieldValue
Client IDThe Application (client) ID from step 1
Client secretThe secret value from step 1
Authorization endpointhttps://login.microsoftonline.com/<directory-id>/oauth2/v2.0/authorize
Token endpointhttps://login.microsoftonline.com/<directory-id>/oauth2/v2.0/token
Refresh endpointhttps://login.microsoftonline.com/<directory-id>/oauth2/v2.0/token
ScopeLeave empty. You set it in step 4.
Enable PKCEOff
Client password authenticationRequest body parameters (default)
The registration ID is not the auth-config ID

After you save, the portal shows an OAuth client registration ID. It is base64 of <directory-id>##<auth-config-id>, and only the second GUID belongs in the Application ID URI. Pasting the base64 verbatim produces a URI that looks right and fails every sign-in with invalid_client.

Paste it into the scratchpad in LangGuard and the guide decodes it for you.

Decoding the registration ID yourself​

The scratchpad does this for you, but the value is plain base64 if you would rather decode it at a terminal.

macOS or Linux

echo '<registration-id>' | base64 --decode

On macOS before Ventura, use base64 -D instead.

Windows (PowerShell)

[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('<registration-id>'))

Both print <directory-id>##<auth-config-id>. Take the second GUID — that is the auth-config id the Application ID URI needs.

If PowerShell reports that the input is not a valid Base-64 string, add = characters to the end of the value until its length is a multiple of four.

Step 3 — Expose the API​

The Entra app → Manage

a. Expose an API​

FieldValue
Application ID URIapi://auth-<auth-config-id>/<client-id> — replace the pre-filled value
Scope nameaccess_as_user
Who can consentAdmins and users
Admin consent display nameFor example, Access LangGuard as the signed-in user
StateEnabled
Authorized client applicationsAdd ab3be6b7-f5df-413d-ac2d-abf1e3fd9c0b (the Microsoft 365 token-store client) with access_as_user ticked

Set the Application ID URI first. Entra will not let you add a scope until it is set.

b. Redirect URI configuration​

The Entra app → Manage → Authentication → Add a platform → Web

FieldValue
Redirect URIhttps://teams.microsoft.com/api/platform/v1.0/oAuthConsentRedirect
Redirect URIhttps://teams.microsoft.com/api/platform/v1.0/oAuthRedirect
Redirect URIhttps://<tenant>.app.langguard.ai/api/mcp-connect/entra/callback

Add all three to the same Web platform. Consent uses the first, sign-in the second. The third is LangGuard's own: when someone first uses an MCP server that needs their personal account (for example Linear), LangGuard signs them in with this app to confirm who they are before they connect it. Replace <tenant> with your LangGuard workspace name.

Step 4 — Finish the OAuth client​

Teams Developer Portal → the registration from step 2

FieldValue
Scopeapi://auth-<auth-config-id>/<client-id>/access_as_user, offline_access

offline_access is required, not optional. Without it Entra issues no refresh token, the token store has nothing to renew with, and Cowork asks the user to sign in again roughly every hour.

Step 5 — Enable and install​

a. Fill in the form in LangGuard​

FieldValue
Enable Entra SSO for the MCP gatewayOn
Directory (tenant) IDFrom the app Overview → Essentials
Accepted audiencesThe client ID and the Application ID URI, one per line

Enter both audiences. Entra puts the client-id GUID in a v2 token and the Application ID URI in a v1 token, and which one you get is a property of the directory, so accepting both covers either. The client-id GUID also turns on the requesting-client check, and the plugin cannot be generated without the Application ID URI.

Click Save and Generate Plugin. The .zip downloads straight away, and a dialog shows the install command. Reset puts the form back to the saved values.

When you edit a value that the plugin carries, the form says so. Generate a new plugin and install it again (see Regenerating the plugin).

Connect sign-in​

Some MCP servers, such as Linear, need each person's own account, so that "my assigned issues" returns that person's issues. The first time someone uses one from Cowork, LangGuard gives them a link to connect it, and signs them in with the same Entra app to confirm who they are. For that, LangGuard needs its own client secret for the app.

  1. In the Entra app, Certificates & secrets → New client secret. Name it for LangGuard. Do not reuse the secret in the Teams OAuth client: separate secrets expire and rotate separately.
  2. In LangGuard, under Connect sign-in on the same page, enter the Application (client) ID and the secret's Value (not its Secret ID), then click Check and save.

LangGuard checks the secret with Microsoft Entra before it saves it, and never shows it again. The section also shows the redirect URI from step 3b.

b. Install the plugin​

On your own machine, with the Microsoft 365 Agents Toolkit CLI:

npx -y @microsoft/m365agentstoolkit-cli auth login m365
npx -y @microsoft/m365agentstoolkit-cli install \
--file-path langguard-cowork-plugin-<version>.zip \
--scope Personal

Use --scope Organization to publish it to everyone. That needs the Teams Administrator role, and the app then waits for approval under Manage apps in the Teams admin center.

Uninstall an older version first

Cowork caches a failed connector and does not retry on an install over the top, so a stale app can keep serving the old gateway settings.

c. Switch it on in Cowork​

Microsoft 365 Copilot → Cowork → Customize → Plugins

Turn the connector on, then click Authenticate on the first task that uses it and sign in with your Entra account.

Personal connections​

For an MCP server that needs each person's own account (for example Linear), everyone connects their own account once. Each person's calls then run with their own access in that service.

How a person connects​

Until they connect, Copilot lists one tool for the server, Connect your <server> account. When they use it, Copilot shows a link. The link opens your LangGuard site, signs them in with Microsoft (step 5a, Connect sign-in), then asks the service for permission. When the page says Connected, they go back to Copilot and ask again.

The link is personal and works for 30 minutes. If someone else opens it, they are refused.

Which permissions are requested​

By default LangGuard asks only for read and search permissions. An admin can change this per server: Settings → AI Gateway → MCP servers → the server's ⋯ menu → Per-user access (see Per-user access). A change applies to new connections; people already connected keep their permissions until they connect again.

Disconnecting​

WhoWhere
The personMy connections: https://<tenant>.app.langguard.ai/api/mcp-connect/connections, also linked from the Connected page. They sign in with Microsoft and disconnect their own connections.
An adminPer-user access → Connected people: one row per person, with Disconnect.
AutomaticallyA connection unused for 90 days is removed. Removing the MCP server removes every connection to it.

Each disconnect also revokes the permission inside the service. If the service does not confirm the revocation, LangGuard still deletes the connection and the admin sees a warning; the person can remove the app in the service's own settings.

A person can also remove the permission inside the service itself. The next time Copilot uses the server, it offers a Reconnect link. The service may not show the app under LangGuard's name: Linear, for example, lists it as MCP.

Regenerating the plugin​

The .zip carries your Directory (tenant) ID and your Application ID URI — its OAuth reference is derived from the two. If you change either one, generate a new plugin and install it again, or the installed connector keeps using the old values. The Enable toggle is a server-side gate and is not in the package, so switching it does not require a new plugin.

Each generated package is stamped with the LangGuard build version, so a regenerated plugin is recognized as an update rather than as the version already installed.

What the gateway checks on each token​

CheckDetail
SignatureAgainst your directory's JWKS, pinned to your Directory (tenant) ID
IssuerYour directory only. Both Entra issuer forms are accepted (sts.windows.net/<tid>/ for v1 tokens and login.microsoftonline.com/<tid>/v2.0 for v2), because which one a directory issues is not something you choose.
AudienceMust match one of your accepted audiences
Requesting clientThe azp (or appid) claim must be the gateway app's own client id. A token with no such claim is rejected. LangGuard takes the client id from the client-id GUID in your accepted audiences. If no accepted audience is a GUID, this check is not made, so enter the GUID.

When Entra SSO is switched off, Entra (JWT) requests to the gateway are rejected. Virtual-key callers are unaffected: that is, callers that use a LangGuard API key or a gateway key.

Troubleshooting​

SymptomCauseFix
Every sign-in fails with invalid_clientThe Application ID URI holds the base64 registration id, or the wrong GUID from itDecode the registration id and use the second GUID
AADSTS900144The Teams OAuth client has no Scope valueSet the Scope in step 4
Cowork asks the user to sign in about every houroffline_access missing from the Teams client ScopeAdd it in the Teams Developer Portal. This change is in the portal only, so you do not need a new plugin
The form says the Application ID URI is required to generate an installable pluginNo accepted audience starts with api://Add the Application ID URI from step 3a to the accepted audiences
Cowork reports "Authentication is still processing" and never finishesThe gateway rejects the token, usually because the requesting-client pin does not matchMake sure the bare client-id GUID is one of your accepted audiences
Tokens rejected on audienceOnly one audience enteredEnter both the client-id GUID and the Application ID URI
The connector worked, then stopped on a dateThe client secret expiredCreate a new secret and update the Teams OAuth client
Changes in LangGuard do not reach CoworkA stale installUninstall the old app, then install the newly generated .zip
Cowork says connecting accounts "isn't set up for your organization yet"No Connect sign-in savedSave the client ID and secret under Connect sign-in (step 5a)
A connect link fails at Microsoft with AADSTS50011 naming …/api/mcp-connect/entra/callbackThe third redirect URI is missingAdd it to the Web platform (step 3b), wait a minute, then open the link again
  • AI Gateway — the rest of the AI Gateway settings page: models, MCP servers and pass-through endpoints
  • Enforcement Mode — whether a policy verdict blocks an MCP tool call through the gateway
  • MCP Server — LangGuard's own MCP server, for agents that operate the platform
  • Single Sign-On (SSO) — Entra ID for logging in to LangGuard, which is a separate setting