Tell A2A clients how to authenticate to a surface
This guide makes an A2A surface’s agent card tell A2A clients how to authenticate, so a client knows where to get a token, or which API key header to send, before it calls the surface. For how the gateway serves and rewrites agent cards, see A2A protocol.
An A2A client learns how to authenticate from the agent card’s securitySchemes field and its list of requirements: security in an A2A 0.3 card, securityRequirements in an A2A 1.0 card. The gateway serves your managed agent’s card at the surface, rewriting its endpoint URLs to the surface and passing these fields through unchanged. When the card describes how your agent authenticates its own callers, rather than the surface’s caller authentication, clients send credentials the surface refuses with 401.
Use this guide when:
- Callers reach an A2A surface with A2A clients that read the agent card to decide how to authenticate.
- The surface’s caller authentication differs from what your managed agent’s card declares.
MCP surfaces advertise their authorization server through authorization server discovery instead; see Enable authorization server discovery for MCP clients.
Prerequisites
- You are signed in to the Agent Gateway dashboard with permission to edit surfaces.
- An A2A surface whose Caller Context authenticates callers, for example with a JWT Bearer method as in Validate bearer tokens on a surface, or an API Key method as in Restrict surface access with API key authentication.
- Access to change the agent card your managed agent serves.
Steps
Note the surface’s caller authentication
- Open the A2A surface on the canvas and select its Caller Context node.
- For each method under Authentication methods, note what callers must send:
- JWT Bearer: the Expected Issuer of its JWT verification strategy, and the Token Header and Scheme,
AuthorizationandBearerby default. - API Key: the HTTP Header Name,
X-API-Keyby default.
- JWT Bearer: the Expected Issuer of its JWT verification strategy, and the Token Header and Scheme,
- Select the Access Point node and copy the Entry point URL from the banner at the top of its panel.
Declare the same authentication in your agent’s card
In your managed agent, set the card’s securitySchemes to describe the methods you noted, and list them in the card’s requirements field. In an A2A 0.3 card, a surface that accepts tokens from your OpenID Connect provider or an API key in X-API-Key declares:
{
"securitySchemes": {
"corporate_idp": {
"type": "openIdConnect",
"openIdConnectUrl": "https://idp.example/realms/agents/.well-known/openid-configuration"
},
"partner_key": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
},
"security": [
{ "corporate_idp": [] },
{ "partner_key": [] }
]
}Each entry in security is one way to authenticate, so a client may use either. Base the OpenID Connect URL on the strategy’s Expected Issuer, and keep the API key’s name the same as the method’s HTTP Header Name. An A2A 1.0 card differs in two ways: it lists the requirements in securityRequirements instead of security, and it wraps each scheme in an object named for its type, such as openIdConnectSecurityScheme. Write both fields in the form the A2A specification gives for your card’s version.
Deploy the updated card
Deploy your managed agent with the updated card. The gateway serves the new card on the next request for it.
Confirm
Replace <ENTRY_POINT_URL> with the surface’s Entry point URL.
Test 1: agent card request without credentials returns the security schemes
curl "<ENTRY_POINT_URL>/.well-known/agent-card.json"Expected: HTTP 200 with the card. Its securitySchemes and requirements fields match what you declared, and its endpoint URLs point at the surface. The gateway serves the card without checking caller credentials, so clients can read it before they authenticate.
Test 2: request with a credential the card describes returns 200
Send an A2A request with a credential in the form the card declares. Replace <YOUR_JWT_TOKEN> with a token from your provider:
curl -X POST "<ENTRY_POINT_URL>" \
-H "Authorization: Bearer <YOUR_JWT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"message/send","id":"test-001","params":{"message":{"role":"user","messageId":"msg-001","parts":[{"kind":"text","text":"Hello"}]}}}'For an API Key method, send -H "X-API-Key: <YOUR_API_KEY>", or the header your method names, instead of the Authorization header.
Expected: HTTP 200 with the managed agent’s response, with no 401 from the gateway.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
The card still shows the old securitySchemes. | The managed agent serves its previous card. | Check that the agent you deployed is the surface’s Target Endpoint URL, and that it serves the new card. |
The card request returns 503. | The Access Point has no caller authentication and Public access is off, so it refuses every request, discovery reads included. | Add a caller authentication method to the Caller Context, then repeat the test. |
Clients follow the card but get 401. | The card names a header, scheme, or issuer that the surface’s Caller Context doesn’t accept. | Compare the card with the methods you noted in step 1, and correct the card. |
Next steps
- Use JWT claims to control access to a surface: Allow or deny callers based on the claims in their tokens.
- Accept JWTs and API keys on one surface: Serve internal callers with tokens and partners with API keys on one surface.
Related
- A2A protocol: How the gateway serves and rewrites agent cards.
- Caller Context element: Every caller authentication method and field.
- Access Point: The Entry point URL, Public access, and readiness rules.
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.