GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — bearerTokenUserBuilder | ADK for TypeScript: API Reference - v2.5.0

  • bearerTokenUserBuilder

Function bearerTokenUserBuilder

  • bearerTokenUserBuilder(token: string): UserBuilder

    Builds an A2aUserBuilder that authenticates A2A requests against a shared bearer token.

    Callers must send Authorization: Bearer <token>; the credential is compared against token in constant time, and a request with a missing, malformed or incorrect one is rejected before the agent or any of its tools is invoked. Serve the surface over HTTPS, or the secret travels in clear text on every call.

    const token = process.env.MY_TOKEN;
    if (!token) {
    throw new Error('MY_TOKEN is not set');
    }
    toA2a(agent, {authentication: bearerTokenUserBuilder(token)});

    A rejected request surfaces as whatever the @a2a-js/sdk handler produces for a failing UserBuilder, which is an HTTP 500 rather than a 401. The guarantee here is that the agent is never reached, not that the caller gets a particular status code.

    Parameters

    • token: string

      The shared secret callers must present; surrounding whitespace is trimmed, because HTTP strips it from header values anyway.

    Returns UserBuilder

    Throws

    If token is empty or contains only whitespace.

    • Defined in core/src/a2a/auth.ts:51
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.