Applies to v1.3.18

Authentication

Purpose

This page explains how a caller proves who it is to the platform: what an administrator configures in the Portal, what the caller sends on each request, and how to obtain a token from the common identity providers. It also explains the difference between a user caller and an application caller, which decides whether a tool can act on a downstream system on a user's behalf.

The Ways In

Method Caller sends Best for Caller is
Bearer token from your identity provider Authorization: Bearer <access-token> Applications and services with an identity in Microsoft Entra ID, Okta, Keycloak or any OpenID Connect provider; applications that already hold a signed-in user's token A user or an application, depending on the token
Application API key X-Api-Key: <api-key> The simplest machine-to-machine setup; no identity provider needed An application
Device flow Authorization: Bearer <access-token>, issued by the platform CLI tools and agents that run where a browser redirect cannot reach them The user who approved the request
Browser sign-in (Authorization Code + PKCE) Authorization: Bearer <access-token>, issued by the platform MCP clients that sign their user in themselves The user who signed in

Send one credential per request. When a request carries both a bearer token and an API key, the bearer token is the one used. The same credentials work on every surface: the MCP endpoint, the tools API and A2A agent hosts.

A request with no credential, or with one the platform cannot validate, is refused with 401 and a WWW-Authenticate: Bearer resource_metadata="…" header pointing at the platform's OAuth metadata. The Gateway refuses a request with no credential at all, or with a malformed or clearly expired token, before it reaches the Runtime.

Bearer Tokens From Your Identity Provider

What the administrator configures

In the Portal, under Security:

  1. Trusted Identity Providers — one entry per token issuer the platform should accept. An entry names the issuer exactly as it appears in the token's iss claim, where to find the signing keys (an authority or OpenID Connect metadata address, or a signing key held in the secret store), the allowed audiences and allowed client ids, and a claim mapping profile. An entry is either global or belongs to one tenant. See Identity & Trust.
  2. Claim Mapping Profiles — which claims in the token carry the subject, user name, email, tenant, roles, scopes, groups and client id. A provider whose tokens use the standard claim names can use the default profile.
  3. Access policies on the tools — the Runtime denies by default. A tool is callable only when an enabled policy matches the caller, on any combination of issuer, client id, role, scope, group and custom claim. See Runtime Authorization.

When allowed audiences are set, a token whose aud is not one of them is refused. When allowed client ids are set, a token must carry one of them — in the client id claim the profile names, or otherwise in client_id, azp or appid — or it is refused.

What the caller sends

curl https://apimapper.example.com/runtime/<tenant-id>/<client-id>/tools \
  -H "Authorization: Bearer <access-token>"

Obtaining a token with client credentials

An application with its own registration in your identity provider obtains a token with the standard OAuth 2.0 client-credentials grant and sends it as above. The requests below are each provider's standard token endpoint; the values in angle brackets are yours. Keep the client secret in a secret store, never in source code.

Microsoft Entra ID

curl -X POST "https://login.microsoftonline.com/<directory-tenant-id>/oauth2/v2.0/token" \
  -d grant_type=client_credentials \
  -d client_id=<application-client-id> \
  -d client_secret=<client-secret> \
  -d scope=<application-id-uri>/.default

Okta (custom authorization server)

curl -X POST "https://<your-okta-domain>/oauth2/<authorization-server-id>/v1/token" \
  -u "<client-id>:<client-secret>" \
  -d grant_type=client_credentials \
  -d scope=<custom-scope>

Keycloak (the client must have service accounts enabled)

curl -X POST "https://<keycloak-host>/realms/<realm>/protocol/openid-connect/token" \
  -d grant_type=client_credentials \
  -d client_id=<client-id> \
  -d client_secret=<client-secret>

Before wiring a token into your application, decode one and compare it with the trusted identity provider entry:

  • iss must match the configured issuer exactly. Identity providers can issue tokens under more than one issuer value for the same directory — Entra ID's issuer differs between its v1.0 and v2.0 token formats, for example — so copy the value from a real token rather than writing it by hand.
  • aud must be one of the allowed audiences, when any are configured. Keycloak adds an audience only when the client is configured with an audience mapper.
  • the client id claim must be one of the allowed client ids, when any are configured.

A token obtained this way identifies an application, not a user. See User And Application Callers for what that means for delegated access.

Forwarding a signed-in user's token

An application that signs its users in with your identity provider can forward the user's access token instead, provided the token is issued for this platform — its issuer is trusted and its audience is allowed. The call then runs as that user. A token issued for another API, such as Microsoft Graph, is refused: see Which token the client sends.

Application API Keys

What the administrator configures

API keys are issued in the Portal from a client application's API keys tab, by an administrator holding the Apps & Tools area's manage role. A key is bound to that client application and its tenant, can be given an expiry, and can carry roles, scopes, groups and custom claims that access policies match exactly as they match a token's claims. Keys can be revoked and deleted. See Toolsets & Client Applications.

An access policy that restricts issuers admits API-key callers only when it includes Platform API key among its allowed issuers. A key comes from no identity provider, so a policy naming only providers' issuers — the platform's own sign-in issuer included — never matches it.

Copy the key when it is issued: it is shown once. The platform keeps only a hash of it, so a lost key cannot be recovered — delete it and issue a new one.

What the caller sends

curl https://apimapper.example.com/runtime/<tenant-id>/<client-id>/tools \
  -H "X-Api-Key: <api-key>"

A key is accepted only on its own tenant and client application's path, and only until it expires. On an A2A agent host, which carries no client application, a key is accepted for its own tenant.

An API key always identifies an application.

Device Flow For CLI Tools

The device flow (OAuth 2.0 Device Authorization Grant, RFC 8628) lets a CLI tool or an agent running in a terminal obtain a token for a person without opening a browser itself. The person approves the request in the Portal from any browser, and the tool receives a token that carries that person's identity and the tenant they chose.

What the administrator configures

Nothing beyond the person's Portal account: the platform is its own authorization server for this flow, and its built-in identity provider is already trusted by the Runtime. What the person can do is what their account can do.

What the tool does

The tool must be a registered OAuth client of the platform. Clients register themselves through the platform's dynamic client registration endpoint (RFC 7591), which requires at least one redirect URI even for a client that will only use the device flow; registrations appear, read-only, on the Portal's OAuth Clients screen. The discovery document lists the registration endpoint along with every endpoint below:

curl https://apimapper.example.com/.well-known/oauth-authorization-server

A client registered without grant_types is registered for the authorization-code grant only, and its device-flow token requests are refused as unauthorized_client. Register the device-code grant explicitly:

curl -X POST https://apimapper.example.com/oauth/register \
  -H "Content-Type: application/json" \
  -d '{
        "client_name": "my-cli",
        "redirect_uris": ["http://127.0.0.1/callback"],
        "grant_types": ["urn:ietf:params:oauth:grant-type:device_code", "refresh_token"],
        "scope": "tools:read tools:invoke"
      }'

The response carries the client_id to use below. A client may also send application_type — web, or native for desktop, command-line and locally hosted clients, as MCP 2026-07-28 asks clients to; any other value is refused with invalid_client_metadata.

  1. Start the flow with the tool's client id:

    curl -X POST https://apimapper.example.com/oauth/device_authorization \
      -d client_id=<oauth-client-id>
    

    The response carries device_code, user_code, verification_uri, verification_uri_complete, expires_in and interval.

  2. Show the person the user_code and verification_uri — or just verification_uri_complete, which pre-fills the code. They open it, sign in to the Portal if they are not already, and approve or deny.

  3. Poll for the token, no more often than every interval seconds:

    curl -X POST https://apimapper.example.com/oauth/token \
      -d grant_type=urn:ietf:params:oauth:grant-type:device_code \
      -d device_code=<device-code> \
      -d client_id=<oauth-client-id>
    

    While the person has not acted, the answer is authorization_pending. Polling too fast answers slow_down: wait longer between polls. A denial answers access_denied, and a request nobody acted on before it expired answers expired_token. On approval the response carries access_token, token_type, expires_in and refresh_token.

  4. Use and renew the token. Send the access token as Authorization: Bearer <access-token>. Renew it with the refresh_token grant at the same token endpoint.

A session can be revoked in the Portal; its tokens stop working on the Runtime on their very next use. See Device Authorization Grant.

Browser Sign-In For MCP Clients

An MCP client that implements MCP authorization needs no token from you. On its first request it receives 401 with a WWW-Authenticate header, follows it to the platform's protected-resource and authorization-server metadata, registers itself, and sends the user through the Portal's sign-in — including an external identity provider and MFA — to a consent step that lists what the client is asking for. The redirect back to the client carries iss, the platform's issuer, which the client compares with the issuer it started with before using the code; the authorization-server metadata announces this with authorization_response_iss_parameter_supported. The four scopes a client can be granted are tools:read, tools:invoke, agents:read and agents:invoke; what the user approves is a ceiling the Runtime enforces on every call, on top of the tools' own access policies. See Consented Scope Enforcement and Connecting MCP Clients.

User And Application Callers

Every authenticated caller is classified as a user or an application:

  • a token whose issuer states the answer is believed — Microsoft Entra ID's idtyp claim says user or app;
  • otherwise, a token with no subject under the claim mapping profile's subject claim, but with a client id, is an application;
  • an API key is always an application;
  • a token obtained with the client-credentials grant is an application; a token from the device flow or browser sign-in, or a signed-in user's forwarded token, is a user.

The difference matters when a tool reaches its downstream system on behalf of the user — a delegated credential obtained by token exchange or On-Behalf-Of. Delegation needs a user to act for, so only a user token can reach such a tool's downstream credential. An application caller is refused with a message saying so, unless the administrator configured that tool's authentication profile to call the downstream system as the application instead. For delegated access the token must also be addressed to the configured client application, not to the downstream API.

Tools whose downstream credential is shared — an API key, basic authentication, a client-credentials token held by the platform — work the same for user and application callers.

The audit trail always records the real caller, whichever credential reached the downstream system. See Delegated Access.

Common Authentication Failures

The 401 body names the reason. The ones integrators meet most often:

Message Meaning
Authentication is required. Provide a valid bearer token or API key. The request carried neither header
No trusted identity provider is configured for issuer '…'. The token's iss does not match any enabled trusted identity provider for this tenant
… Client '…' is not allowed for provider '…'. The provider restricts client ids and the token's client id is not one of them
The session backing this access token has been revoked. A platform-issued token whose session was revoked in the Portal

Repeated invalid tokens and API keys are counted and raise security alerts for the platform's operators, so fix the credential rather than retrying.

SDK Side

The SDKs take a credential once, at construction, and add it to every request: an API key, OAuth2 client credentials with automatic renewal, or a delegated bearer token forwarded per request. See SDK Authentication.