Skip to main content
Inbound authentication verifies the identity of requests coming into the agent. VeADK supports API keys and OAuth2.
Direct reuse through from_veidentity(client_secret=...), A2A 1.0 AgentCard parsing, and managed API key resolution are unreleased Preview additions verified at the revision below. They are not included in VeADK 1.1.13. Install this revision in a separate virtual environment when using these additions

API key authentication

URL parameters can appear in browser history, access logs, and forwarded links. Use HTTPS and redact credential-bearing URLs from logs. Successful key validation still requires resource authorization
An API key verifies the caller’s identity and authorizes access to API resources with a single string secret. The VeFaaS API gateway deployment described here passes the API key in the URL’s token parameter. Follow the corresponding API documentation for other services.
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: Install the example dependencies with pip install fastapi uvicorn. Call setup_oauth2() once per application; the later fragments are alternative configurations, not additional setup calls Prepare an existing user pool and Web client, and register http://localhost:8000/oauth2/callback. Set OAUTH2_USER_POOL_NAME and OAUTH2_CLIENT_NAME, and provide cloud credentials allowed to read those resources. This example is for local HTTP development only; use HTTPS and restore cookie_secure=True for deployment
app.py
Save as app.py and run uvicorn app:app --host 127.0.0.1 --port 8000. Before login, /api/profile should return 401. Open /oauth2/login in a browser, complete login, then request the profile again to receive authenticated: true from_veidentity() enables resource creation and callback registration by default; this example disables both. Automatic creation requires the corresponding permissions and a valid callback address. Starlette usage is the same To reuse existing resources, disable auto-creation:
Local development needs HTTPS cookies disabled:
To reuse an existing user pool and client by UID, provide both client_uid and client_secret to skip the client lookup during startup:
For a provider other than VeIdentity, construct OAuth2Config directly. This alternative configuration fragment is for providers that issue JWT access tokens. Set endpoint, issuer, and public-key environment variables from the provider’s OpenID Connect metadata, and set OAUTH2_AUDIENCE to the audience accepted by this API. Do not assume that any client ID is a valid audience
Direct construction does not discover jwks_uri; JWT validation cannot complete without a public key set. For opaque access tokens, set use_introspection=True and introspection_url, and supply introspection client credentials required by the provider 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.

Application integration parameters

setup_oauth2() returns an OAuth2Handler that manages OAuth2 and registers authentication routes and middleware After creating app and config, replace the original setup_oauth2() call with this fragment to customize paths. Update both config.redirect_uri and the provider registration to match the new callback URL

VeIdentity configuration parameters

OAuth2Config.from_veidentity() accepts the parameters below. When session_timeout_seconds is omitted, it attempts to use the client’s configured refresh-token lifetime; if unavailable, the OAuth2Config default remains

OAuth2Config parameters

Endpoints and authorization requests

Sessions and cookies

Access token validation

Storage and request behavior

When fetching user info from the userinfo endpoint, only fields safe to store in a browser session cookie are retained: sub, email, email_verified, name, given_name, family_name, preferred_username, picture, locale, updated_at, plus the field configured via user_id_field. Only values of type string, integer, float, or boolean are kept, to prevent the session cookie from exceeding browser size limits. The /oauth2/userinfo endpoint returns these filtered fields.

Sharing OAuth state across processes

The default InMemoryStateStore is for a single process. All instances of a distributed application need a shared state store that consumes each state only once This fragment replaces the setup_oauth2() call and reuses app and config from above. Install the redis package, prepare Redis 6.2 or later with GETDEL support, and set REDIS_URL. Use an application-specific key prefix shared by all its instances, and configure production connections and credentials for your deployment
create_state() returns a random state and stores the redirect destination and PKCE verifier. validate_and_consume_state() atomically reads and deletes the record, returning None for an invalid state. A custom store manages its own expiry, capacity, and connection lifecycle; state_max_entries does not limit Redis records automatically

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.

Identity propagation in A2A calls

In a call chain that uses the AgentKit A2A registry, VeADK can pass credentials from the current request to a downstream agent so that it can authorize the call under the original user identity and trust context.
Credentials are sent to the resolved downstream A2A endpoint. Call only trusted downstream agents, and give inbound tokens only the permissions required for the task.
For a downstream agent that declares OAuth2, VeADK first sends the propagated Bearer JWT. It falls back to an OAuth2 M2M token and retries once only when the downstream endpoint explicitly returns 401 Unauthorized. Other status codes and call failures do not trigger M2M fallback, which prevents application or service failures from being treated as an expired identity token.

Managed API Key credential authentication

When the downstream AgentCard declares a credential provider in capabilities.extensions (containing credentialProviderName and poolName), and security / securitySchemes did not produce a usable authentication header, VeADK queries the identity service for the API Key managed by that credential provider and constructs the authentication header according to the credential metadata returned (header name, prefix, etc.). This mechanism uses Agent Identity to centrally manage API keys, requiring no manual API Key configuration on the VeADK side.
VeADK supports parsing A2A 1.0 AgentCards: when the AgentCard does not provide a top-level url field, VeADK resolves the endpoint from supportedInterfaces by protocol binding type and version, preferring JSONRPC bindings with protocol version 1.0.

Identity propagation to the skills sandbox

When execute_skills calls the skills sandbox, it likewise forwards the inbound identity credential. VeADK reads the credential stored under the inbound_auth credential key from the credential service and sends it in the inbound_auth request header to the sandbox’s A2A endpoint, so the sandbox workflow runs under the original user identity. If the current request carries no inbound credential, the header is omitted. See the skill sandbox execution section in Code sandboxes.

Session and deployment limits

cookie_signing_secret signs browser sessions and falls back to client_secret. Public clients should set a stable signing secret explicitly. Signing prevents tampering; it is not encryption. Multiple instances need a shared signing secret and OAuth state store. Public callback URLs must exactly match the registered client URL
Last modified on September 19, 2026