Skip to main content
Inbound authentication verifies the identity of requests coming into the agent. VeADK supports API keys and OAuth2.

API key authentication

An API key verifies the caller’s identity and authorizes access to API resources with a single string secret. VeADK passes the API key in the URL’s token parameter.
API keys apply only to the A2A / MCP Server deployment mode; they are not recommended for the VeADK Web mode, which should use OAuth2 instead.
Select API-key auth when scaffolding an agent, or add --auth-method=api-key when deploying an existing project. The API gateway then validates the API key carried in the token URL parameter on each request.

OAuth2 single sign-on

OAuth2 is an open authorization framework: instead of exposing account credentials, it grants limited access via tokens, so a single login lets users reach multiple related applications without re-authenticating. VeADK offers two integration paths:

API gateway

For VeADK Web apps deployed on VeFaaS, where the API gateway runs the OAuth2 flow.
The API gateway mode requires API gateway version 4.0.0 or later.
Select OAuth2 when scaffolding an agent, or add --auth-method=oauth2 when deploying an existing project; VeADK creates the Identity user pool and client for you. To reuse existing resources, pass --user-pool-name and --client-name at deploy time. After deploying, create users in Agent Identity:
1

Open the user pool

In the Volcengine console, go to Agent Identity, select Authentication › User Pools, and choose your pool.
2

Create a user

On the pool’s Users tab, click New User, fill in the details, and confirm.
When a user visits the app, the API gateway guides them through login; afterwards you can read the user’s JWT from the Authorization header.

Starlette / FastAPI middleware

For local development or self-hosted deployment, VeADK’s middleware handles OAuth2 inside the app and supports any Starlette-based framework (including FastAPI). Prefer OAuth2Config.from_veidentity(), which auto-configures a VeIdentity user pool:
This creates the user pool and client (if missing), registers the callback URL, and configures the OAuth2 endpoints. Starlette usage is identical — swap FastAPI() for Starlette(). To reuse existing resources, disable auto-creation:
Local development needs HTTPS cookies disabled:
To use an OAuth2 provider other than VeIdentity, construct OAuth2Config directly:
The middleware registers these routes automatically: You can exempt paths from auth: exempt_paths=["/health", "/metrics"] (exact match) and exempt_prefixes=["/public/", "/static/"] (prefix match). The middleware responds by request type: browser requests redirect to the login page; API requests get a 401. API requests are detected via the Accept: application/json header, a path prefix (default /api/), or the X-Requested-With: XMLHttpRequest header, and can be customized with api_path_prefixes. Key OAuth2Config.from_veidentity() parameters: Key OAuth2Config parameters:
The default InMemoryStateStore fits single-process deployments only. For distributed setups, implement a state store backed by Redis or similar and pass it via setup_oauth2(app, config, state_store=...).

OAuth2 JWT authentication

OAuth2 JWT auth combines the OAuth2 framework with JWT, carrying the authorization token as a JWT. It applies to A2A / MCP Server. Select OAuth2 when scaffolding an agent, or add --auth-method=oauth2 when deploying; VeADK creates the Identity user pool, or reuses one via --user-pool-name. Then create an M2M client in the pool and exchange its credentials for a JWT:
When a user calls the app, the API gateway validates the JWT they carry; read it from the Authorization header.

Propagate tokens to downstream A2A agents

When the AgentKit A2A Registry is enabled and the current agent calls a downstream registry agent, VeADK 1.0.3 can propagate these inbound credentials: Only bearer-form Authorization values are propagated. If a downstream OAuth2 request returns 401 with the inbound JWT, VeADK obtains a token from the M2M OAuth2 configuration in the downstream Agent Card and retries once. For tasks that cannot obtain a TIP token from an inbound request, set it with an environment variable. These names are accepted in order; prefer the first:
Compatible names are AGENTKIT_UPSTREAM_TIP_TOKEN, A2A_REGISTRY_UPSTREAM_TIP_TOKEN, VE_TIP_TOKEN, X_VE_TIP_TOKEN, and TIP_TOKEN.
JWTs and TIP tokens represent the caller’s identity. Propagate them only to trusted downstream agents, and ensure logs, errors, and traces do not record token values.
Last modified on September 19, 2026