Microsoft Copilot and OAuth
Some MCP clients cannot send a token header. Microsoft Copilot Studio, Microsoft 365 Copilot agents (Teams), VS Code and the web versions of other assistants connect to a remote MCP server with OAuth instead: the client opens a Clarive page, the user signs in, allows the client, and the client gets a token of its own for that user.
Clarive is its own OAuth authorization server for /mcp. Each user signs
in as themselves, with their own permissions. There is no shared token.
What the user sees¶
- The client (Copilot, Teams, VS Code...) opens
https://<your server>/oauth/authorize. - A user without a Clarive session gets the normal Clarive login, whatever it is: local accounts, LDAP, SAML2 or CAS single sign-on.
- The consent page names the client, the user and where the browser goes back to, and asks to Allow or Cancel. Make changes as you is checked when the client asked for write access; unchecked, the client only gets the tools that change nothing.
- The client gets an access token (one hour) and a refresh token, and keeps working without asking again.
Every OAuth token acts as its user, with the user's roles and projects at the moment of each call. A user that is disabled stops working at once.
An OAuth token cannot make other credentials: the operations that mint API
tokens, api keys or OAuth client secrets (auth.create_token,
auth.update_token, auth.set_token_active, auth.regenerate_api_key,
oauth.create_client, oauth.update_client, oauth.rotate_client_secret)
are not offered to it, so nothing outlives disconnecting the app. While
simulating another user, the consent page refuses to allow apps.
Microsoft Copilot Studio¶
In the agent, Tools > Add a tool > New tool > Model Context Protocol:
- Server URL:
https://<your server>/mcp. Add?mode=compactfor a short list of tools (see Connecting agents), or?namespaces=topic,jobfor a few namespaces. - Authentication: OAuth 2.0.
Then one of the two types:
Dynamic discovery (simplest). Select it and Create. Copilot Studio reads the discovery documents, registers itself and is ready. Nothing to do in Clarive.
Manual. Create a client for it in Clarive first (see Clients made by an administrator), then fill in:
| Copilot Studio field | Value |
|---|---|
| Client ID | the client_id (claoc_...) |
| Client secret | the client_secret (claocs_...) |
| Authorization URL | https://<your server>/oauth/authorize |
| Token URL template | https://<your server>/oauth/token |
| Refresh URL | https://<your server>/oauth/token |
| Scopes | read write, or read for read-only |
After Create, Copilot Studio shows its callback URL
(https://global.consent.azure-apim.net/redirect/...). Put it on the
client: oauth.update_client with redirect_uris.
Microsoft 365 Copilot agents (Teams)¶
A declarative agent with an MCP plugin (Agents Toolkit, Work IQ Dev Tools):
- Dynamic client registration (
oauth-dynamic): nothing to do in Clarive. Microsoft registers a confidential client, gets a secret and uses PKCE. - Static OAuth: create a client with the redirect URI
https://teams.microsoft.com/api/platform/v1.0/oAuthRedirectand use its id, secret and the URLs above in the auth config. The base URL of the auth config ishttps://<your server>/mcp.
VS Code, Claude and other clients¶
Give them the URL https://<your server>/mcp with no token: they find the
OAuth endpoints, register themselves and open the browser. Clients that run
on your machine call back on http://127.0.0.1:<port>/..., which dynamic
registration allows.
Clients made by an administrator¶
For the "Manual" and static setups, an administrator (root) creates a client
per application with the oauth operations, from the clarive CLI, the REST
API or on the server:
clarive oauth create-client --name "Contoso Copilot" \ --redirect-uris https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect cla api-call oauth.create_client \ '{"name":"Contoso Copilot","redirect_uris":["https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect"]}'
The answer has the client_id, the client_secret (shown only once) and the
URLs to paste in the client. Redirect URIs are exact and must be https, or
http on 127.0.0.1/localhost.
| Operation | What it does |
|---|---|
oauth.create_client |
New client: name, redirect URIs, scopes (read write or read) |
oauth.list_clients |
Clients made by administrators and registered dynamically |
oauth.get_client |
One client, with the URLs to configure it |
oauth.update_client |
Name, redirect URIs, scopes; active: false disables it and ends all its connections |
oauth.rotate_client_secret |
New secret; the old one stops working, connections stay |
oauth.delete_client |
Deletes the client and ends its connections |
Connected apps¶
Users see and disconnect the apps they allowed:
| Operation | What it does |
|---|---|
oauth.list_grants |
The apps connected to your account (another user's with action.admin.users) |
oauth.revoke_grant |
Disconnects one: its tokens stop working at once |
auth.logout called with an OAuth token disconnects that app too.
Audit¶
event.oauth.grant: a user allowed an app (user, client, scopes, redirect URI, address).event.oauth.client: a client was registered, created, changed, had its secret rotated or was deleted.- Every tool call keeps firing
event.mcp.call; with an OAuth token itstoken_prefixstarts withclaoat_. See Auditing and control.
Configuration¶
All optional, under oauth: in the config file:
oauth: enabled: 1 # 0 turns OAuth off: /mcp takes API tokens only issuer: https://clarive.example.com dynamic_registration: 1 # 0: only clients made by an administrator access_token_minutes: 60 refresh_token_days: 90 # since the last refresh dcr_redirect_uris: # replaces the list below - 'https://*.consent.azure-apim.net/redirect/*'
issuer is the public URL of Clarive. Without it Clarive works it out from
the request (Host, X-Forwarded-Host, X-Forwarded-Proto, Cloudflare's
CF-Visitor) and the url of the config. Set it when a proxy in front of
Clarive hides the public host or scheme: the discovery documents must name
the URL the clients use, https included.
dcr_redirect_uris limits where dynamically registered clients may send
the user back. * in the host stands for one or more labels, in the port for
any port, in the path for anything. The default list:
https://*.consent.azure-apim.net/redirect/* Copilot Studio https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect Microsoft 365 Copilot https://teams.microsoft.com/api/platform/v1.0/oAuthConsentRedirect https://vscode.dev/redirect https://insiders.vscode.dev/redirect https://claude.ai/api/mcp/auth_callback https://claude.com/api/mcp/auth_callback http://127.0.0.1:*/* clients on the user's machine http://localhost:*/* http://[::1]:*/*
Any other application needs a client made by an administrator.
Dynamic registration lets anybody register a client with any name, as long
as its redirect URI is in the list. The Copilot Studio and Teams redirect
hosts are shared by every Microsoft tenant, so someone could start a
connection in their own tenant and send the link to one of your users: the
consent page says the application registered itself and where it goes back
to. Where that is not acceptable, set dynamic_registration: 0 and create a
client per application.
Behind a proxy or CDN, make sure /.well-known/* and /oauth/* reach
Clarive like /mcp does.
Endpoints¶
| Path | Standard |
|---|---|
GET /.well-known/oauth-protected-resource (also with /mcp at the end) |
RFC 9728 protected resource metadata |
GET /.well-known/oauth-authorization-server |
RFC 8414 authorization server metadata |
POST /oauth/register |
RFC 7591 dynamic client registration |
GET /oauth/authorize |
Authorization code with PKCE (S256), the consent page |
POST /oauth/token |
authorization_code and refresh_token grants; client_secret_basic, client_secret_post, or none for public clients |
POST /oauth/revoke |
RFC 7009 token revocation |
A request to /mcp without a token answers 401 with
WWW-Authenticate: Bearer realm="clarive", resource_metadata="https://<your server>/.well-known/oauth-protected-resource",
where clients start.
Details:
- Public clients (no secret) must use PKCE; confidential clients may.
Only
S256is accepted. - Codes last ten minutes and work once.
- Refresh tokens are rotated on every use. The old one keeps working for two minutes, for clients that refresh twice at once. A public client that uses an old one later loses the whole connection.
- A refresh never gets more than the user allowed nor than the client may now: asking for more gets less instead of an error, and a client made read-only by an administrator gets read-only tokens from its next refresh.
- Clients registered dynamically that never got a token are dropped after half a year. Registrations are limited per address and in total, per hour.
- Only this server's
/mcpmay be theresource(RFC 8707). - OAuth access tokens only open
/mcp. The REST API and the clarive CLI keep using API tokens. - Tokens, codes and client secrets are stored hashed.