Configure per-caller Credential Delegation
By the end of this guide, your surface injects each caller’s OAuth token on every forwarded request. Callers complete a one-time OAuth consent step to authorise access. The gateway stores their token and injects it automatically on subsequent calls.
Credential Delegation stores per-caller OAuth tokens in the gateway and injects them transparently, without exposing the OAuth App credentials to callers. Without it, calls run under a shared token, masking per-caller identity in the upstream API’s audit log. See Credentials and Caller context binding.
Use this guide when callers need to access a third-party API under their own account. This pattern works on any surface type (A2A or MCP) and with any OAuth 2.0 Authorization Code API.

From version 1.0.4, the gateway keys stored tokens by how each caller was identified, not by the caller’s name alone. After the upgrade, each caller connects their delegated accounts again. Tokens stored before the upgrade stay on the Credential Tokens tab of the Credentials page until you revoke them.
Prerequisites
Do these steps before opening the gateway dashboard:
Create a GitHub OAuth App at github.com/settings/developers. Enter this callback URL exactly during creation:
https://GATEWAY_HOST/v1/identity/oauth/callback/githubNote the Client ID and generate a Client Secret.
Store the credentials as gateway secrets. Follow Manage secrets to create:
- Secret ID
GITHUB_CLIENT_ID, value: your App’s Client ID. - Secret ID
GITHUB_CLIENT_SECRET, value: your App’s Client Secret.
- Secret ID
Never paste secret values directly into provider fields. Always reference them by Secret ID.
Have these ready in the gateway:
- A running gateway instance with Power User or Administrator role, and your public hostname (
GATEWAY_HOST). - An existing MCP surface open in the canvas. See MCP surface starter if you need one.
- A JWT verification strategy for your identity provider, so the gateway can validate callers’ tokens. See Validate bearer tokens on a surface to create one. For Microsoft Entra callers, set the strategy’s Caller identity claim to
oidwhen you create it, because Entra’ssubdiffers for each application. This claim decides which delegated credentials a caller uses, and it can’t be changed after the strategy is created. - A JWT issued by a trusted identity provider for each caller. The token must carry an
issclaim and a unique per-user value in the strategy’s caller identity claim:subby default, oroidfor Entra. If you use API key auth instead, give each caller their own credential: one key per caller under the API Keys tab on the Secrets page for API Key (provider), or one secret per caller for API Key (secret store). - VP Auditing set to keep delegation events, so Test 3 has entries to show. Under Settings › Security, on the VP Audit card, turn on Enable VP Auditing and select Consent Required, Consent Granted, and Token Injected under Events to keep, then select Save. No events are selected by default.
Steps
Create a credential provider for GitHub
- In the sidebar, select Credentials, then select the Credential Providers tab.
- Select Add Provider.
- Fill in the fields:

| Field | Value |
|---|---|
| Name | GitHub |
| Provider Type | OAuth 2.0, Authorization Code (3-legged, user consent) |
| Authorization Endpoint | https://github.com/login/oauth/authorize |
| Token Endpoint | https://github.com/login/oauth/access_token |
| Client ID Secret | GITHUB_CLIENT_ID |
| Client Secret | GITHUB_CLIENT_SECRET |
| Default Scopes | repo, read:user |
| Callback URL Host | Select the listen address matching https://GATEWAY_HOST. |
| Callback URL Route | github (auto-filled from Name; immutable after creation). |
Leave Enable automatic token refresh checked (its default) so the gateway can refresh the caller’s token automatically without asking them to reauthorise.
- Confirm the Callback URL shown on the form matches what you entered in your GitHub App:
https://GATEWAY_HOST/v1/identity/oauth/callback/github. - Select Create.
Set the Managed Agent target

- Open your MCP surface in the canvas.
- Select the Managed Agent node.
- Set Target Endpoint URL to
https://api.githubcopilot.com/mcp/. - Close the editor.
The gateway proxies MCP calls directly to this endpoint. The GitHub Copilot MCP server handles all tool definitions and execution.
Add Caller Context
- Drag a Caller Context element from the palette onto the canvas.
- Select the Caller Context node. Under Authentication methods, it lists one method, JWT, the default.
- On the method row, select Configure ↗ to open the full configuration editor. Authentication Method shows JWT Bearer.
- Select your strategy from the JWT Verification Strategy dropdown. The field is required.
- Accept the default Token Header (
Authorization) and Scheme (Bearer). - Close the editor.
If your callers authenticate with API keys rather than JWTs, select API Key (provider) or API Key (secret store) in Authentication Method and keep HTTP Header Name at X-API-Key. When you do, the Identity element in Step 4 must use From API Key rather than From JWT Claims, and every method of the Caller Context must be an API key method. Step 4 explains why.
Add the Identity element
The Identity element derives a stable per-caller DID from the validated credential. This DID appears as the workload identity in audit records and workload binding attestations.
- Drag an Identity element from the palette onto the canvas.
- Select the Identity node.
- Set Identity Extraction Type to From JWT Claims.
- Set JWT Claim to
sub. Useoidif your identity provider is Microsoft Entra. - Close the editor.
JWT bearer auth (recommended): From JWT Claims extracts sub or oid from the validated token, deriving a stable per-caller DID for audit records and workload binding. This is separate from vault scoping: the stored token is keyed to the JWT’s issuer (iss) and the Caller identity claim of the JWT verification strategy, sub by default, regardless of which claim you select here. Setting oid here gives Entra callers a more reliable DID for audit and workload-binding purposes, but does not change which token a caller’s requests resolve.
API key auth: An API key carries no user claims, so From API Key identifies each caller by the API key it presents. How far that identification reaches depends on the Caller Context method:
- API Key (provider): each key is its own caller, with its own DID and its own stored tokens. Issue one key per caller.
- API Key (secret store): the secret is the caller, so every key value in one secret shares one DID and one set of stored tokens. Give each caller their own secret.
Enable Credential Delegation

Drag a Credential Delegation element from the palette and connect it to the Managed Agent node.
Configure the credential binding:
Field Value Credential Provider GitHubScopes repo read:userConsent Mode On demand Required For All outbound requests Inject As Bearer header Consent Mode controls what the agent receives on the first call when no token is stored yet.
Mode What the agent receives When to use On demand (default) A consent_requiredresponse with the authorisation URL. The agent or client retries after the user completes OAuth.Most clients. No MCP-specific support required. Pre-authorize The session is blocked at initialisation. OAuth must complete before any tool call proceeds. Clients that can display an auth prompt before the session starts. Elicit An inline MCP elicitation prompt. The gateway holds the tool call open while OAuth completes, then resumes automatically. Clients that support MCP elicitation. No out-of-band retry required. Required For set to All outbound requests means the gateway checks for a stored GitHub token before every forwarded call, including
tools/list. Until this caller has a stored token, the gateway answers each call with aconsent_requiredresponse immediately, instead of forwarding the request.Specific MCP tools only limits the binding to a
tools/callfor the tools you list, on calls to this surface’s Target. Tool-scoped bindings stay with the Target, and each All outbound requests binding also applies on every Transit Point of the surface. See Where each binding applies. A Transit Point that receives a binding also needs an agent identity and a transit token that names the caller. See Requirements for a Transit Point with delegated credentials.Close the editor.
If the Managed Agent’s Endpoint Type is via Gateway Connection, the remote gateway receives the caller’s token only when Send delegated credentials over Fabric is on in the Managed Agent panel. The switch is off by default. See Managed Agent.
Save the surface
Select the green checkmark (Create surface) or the disk icon (Save changes). Changes apply immediately through hot reload.
On every subsequent request the gateway:
- Authenticates the caller via
Authorization: Bearer(orX-API-Keyheader for API key auth). - Derives the caller’s unique identity from the JWT’s issuer and the strategy’s caller identity claim,
subby default (or from the API key if using API key auth). - Checks for a stored OAuth token for that identity. If none is stored, returns
consent_required. - Injects the token as
Authorization: Bearer <oauth-token>on the forwarded request toapi.githubcopilot.com/mcp/.
Restrict access by Entra group membership (optional)
If callers authenticate with Microsoft Entra, add a surface-scope OPA policy to restrict access to specific security groups.
From the surface palette, drag a Policy element onto the canvas and open the policy editor. Enter:
package surface.policy
default allow := false
allow if {
input.source_auth.method == "jwt_bearer"
input.source_auth.claims.iss == "https://login.microsoftonline.com/TENANT_ID/v2.0"
"ALLOWED_GROUP_ID" in input.source_auth.claims.groups
not "RESTRICTED_GROUP_ID" in input.source_auth.claims.groups
}Replace TENANT_ID, ALLOWED_GROUP_ID, and RESTRICTED_GROUP_ID with values from your Entra configuration. Save and publish the policy.
Some Entra app registrations do not include the groups claim by default. If this policy rejects all requests even when group membership is correct, confirm that group claims are enabled in your app registration’s token configuration.
Confirm
Replace GATEWAY_HOST and JWT_TOKEN with your actual values. JWT_TOKEN is a valid JWT issued by the identity provider you have configured as the gateway’s trusted issuer.
The commands below call tools/list and tools/call because the sample target is an MCP server. If your target is an A2A agent, replace the request body with an A2A equivalent, for example "method": "message/send". The consent flow, consent_required response shape, and audit log behaviour are identical regardless of surface type.
If your surface uses API key authentication, replace -H "Authorization: Bearer JWT_TOKEN" with -H 'X-API-Key: YOUR_KEY' in all commands below. Single quotes keep the shell from changing a key that contains $ or !.
Test 1: first call should return consent_required
curl -X POST "https://GATEWAY_HOST/agents/call/github" \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}'Because Required For is set to All outbound requests, the gateway checks for a stored OAuth token before forwarding. When no token is stored for this caller:
{
"type": "https://affinidi.com/atg/errors/consent-required",
"title": "Credential Delegation Consent Required",
"status": 401,
"detail": "This channel requires delegated credentials. The user must authorize access via the provided URLs.",
"consent_required": [
{
"provider_name": "GitHub",
"authorization_url": "https://github.com/login/oauth/authorize?response_type=code&client_id=...&redirect_uri=...&scope=repo+read%3Auser&state=...",
"scopes": ["repo", "read:user"]
}
]
}Open the authorization_url in a browser, sign in to GitHub, and grant access. The gateway stores the token, scoped to this caller’s identity. Run the same command again. Expected: a JSON-RPC result listing the GitHub Copilot tools (get_me, list_repositories, create_issue, and others).
Test 2: tools/call should return data from the caller’s GitHub account
curl -X POST "https://GATEWAY_HOST/agents/call/github" \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"2","method":"tools/call","params":{"name":"get_me","arguments":{}}}'Expected: the gateway injects Authorization: Bearer <oauth-token> and the tool returns the caller’s GitHub profile. Each caller sees only their own GitHub data.
Test 3: audit log should show delegation events for this caller
- In the dashboard, navigate to Credentials and select the Credential Delegation Audit tab.
- Use the search field to filter entries by
github.
Look for these event types produced during your test:
| Event badge | When it appears |
|---|---|
| Consent Required | The gateway returned consent_required on the first call; no token was stored yet. |
| Consent Granted | The user completed the OAuth flow and the gateway stored the token. |
| Injected | The stored token was injected into a forwarded request on a subsequent call. |
Each entry shows the provider name and the caller’s identity hash. Confirm that the Injected entries show github as the provider, confirming the token is stored per caller and is not shared.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
consent_required on every call, even after completing OAuth | The OAuth callback did not reach the gateway, or the token was not stored. | Check Credentials → Credential Delegation Audit for a consent_granted event with provider_id = github. Confirm the callback URL is publicly reachable from GitHub’s servers. |
GitHub returns redirect_uri_mismatch | The callback URL in the GitHub App does not match the gateway’s. | Copy the full callback URL from the credential provider form and paste it into the GitHub App Authorization callback URL field. Check for trailing slash differences. |
401 Unauthorized with “Caller credential missing or invalid” and no consent_required body | The surface’s Access Point is closed (the default from version 1.0.4) and refused the caller’s credential before policy ran: the token or key is missing, expired, or doesn’t match the Caller Context. | Send a valid credential in the header the Caller Context reads. Confirm the JWT Verification Strategy still exists, or that the API key is active. A policy denial returns 403 rather than 401. |
tools/list returns consent_required | Required For is set to All outbound requests. The gateway checks for a stored OAuth token before every forwarded call, not just tools/call. | This is expected behaviour. Complete the OAuth flow first, then retry. |
| All callers trigger the same consent flow, or share each other’s tokens | Callers share one credential, or the Identity element is missing or misconfigured. | With API Key (secret store), every key value in one secret is one caller, so give each caller their own secret, or switch to API Key (provider) with one key per caller. Confirm the Identity element is present and its Identity Extraction Type matches the auth method: From JWT Claims for JWT bearer, From API Key for API key auth. |
Gateway returns 503 with Delegated credentials unavailable (on MCP, a JSON-RPC error with code -32603) | The binding applies, but the gateway cannot resolve the credential: the credential provider was deleted or cannot be read, an API key secret cannot be read, a client credentials token request failed, the stored token cannot be read, or consent cannot be asked for. The gateway refuses the request rather than forwarding it without the credential. | Under Credentials › Credential Providers, confirm the provider still exists. Confirm that the secrets it references still exist on the Secrets page. For a client credentials provider, confirm its token endpoint accepts the client. |
Every call returns 403 “Identity Required for Credential Delegation” | The caller’s credential names nobody the gateway can key tokens to, for example a JWT without an iss claim or without the strategy’s caller identity claim (sub by default). | Have your identity provider include iss and that claim in the token. |
A call through a Transit Point returns 403 while the same caller’s calls to the Target succeed | The Transit Point has no agent identity, or its transit token names no caller. | Add an Identity element on the Managed Agent → Transit Point edge, or configure caller identity on the Access Point. Keep Require transit token on for that Transit Point. See Requirements for a Transit Point with delegated credentials. |
Gateway returns 502 Bad Gateway | The gateway cannot reach api.githubcopilot.com/mcp/. | Confirm the gateway has outbound HTTPS access and the Target Endpoint is exactly https://api.githubcopilot.com/mcp/. |
| Stored token expired and calls start failing | GitHub OAuth Apps do not issue long-lived refresh tokens by default. | The caller must re-authorise by visiting the authorization_url again. For persistent access, consider a GitHub App (which supports refresh tokens) instead. |
| OPA policy rejects all calls even when credentials appear correct | Issuer claim mismatch, or groups claim absent from the JWT. | Confirm the iss value in the Rego policy matches the token’s iss exactly, including any trailing slash. Verify that group claims are enabled in the IdP app registration’s token configuration. |
| Delegation audit log shows no entries | VP Auditing is off or keeps no delegation events, or the Identity element is not configured. | Under Settings › Security › VP Audit, turn on Enable VP Auditing and select the delegation events under Events to keep. Then confirm the Identity element is present and its Type matches the auth method. The gateway records delegation events only when it can scope them to a valid per-caller identity. |
Next steps
- Apply policy to outbound calls: add an OPA policy to restrict which GitHub Copilot tools each caller can invoke.
- Caller context binding: understand how the gateway binds caller identity to a verifiable audit record on every delegated call.
- Carry caller claims through your managed agent: when your managed agent also calls out through a Transit Point, choose which caller claims travel with it.
Related
- Credentials: conceptual model for credential providers, OAuth flows, consent modes, and per-user token isolation.
- Secrets reference: how to store and reference secret material safely.
Glad to hear it. Thanks for letting us know.
Sorry to hear that. Thanks for letting us know.
Still stuck? Ask the community on Discord or contact us.