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’stoken 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.
--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.
--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.
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). PreferOAuth2Config.from_veidentity(), which auto-configures a VeIdentity user pool:
FastAPI() for Starlette().
To reuse existing resources, disable auto-creation:
OAuth2Config directly:
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:
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.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:
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.
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.
Identity propagation to the skills sandbox
Whenexecute_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.