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 — tokenToSchemeCredential | ADK for TypeScript: API Reference - v2.5.0

  • tokenToSchemeCredential

Function tokenToSchemeCredential

  • tokenToSchemeCredential(
        tokenType: "apikey" | "oauth2Token",
        location?: "cookie" | "query" | "header",
        name?: string,
        credentialValue?: string,
    ): [AuthScheme, AuthCredential | undefined]

    Creates an AuthScheme and AuthCredential for an API key or a bearer token.

    Parameters

    • tokenType: "apikey" | "oauth2Token"

      'apikey' or 'oauth2Token'.

    • Optionallocation: "cookie" | "query" | "header"

      Where the API key travels. Ignored for 'oauth2Token', because a bearer token always travels in the Authorization header.

    • Optionalname: string

      The name of the header, query parameter, or cookie.

    • OptionalcredentialValue: string

      The API key or token value. Omit it to build the scheme alone.

    Returns [AuthScheme, AuthCredential | undefined]

    A [scheme, credential] pair. The credential is undefined when credentialValue is omitted.

    Example

    // API key in a header.
    const [scheme, credential] = tokenToSchemeCredential(
    'apikey', 'header', 'X-API-Key', 'your_api_key_value');

    Example

    // OAuth2 bearer token in the Authorization header.
    const [scheme, credential] = tokenToSchemeCredential(
    'oauth2Token', 'header', 'Authorization', 'your_bearer_token_value');

    Throws

    Error For an unsupported token type or API key location.

    • Defined in core/src/tools/openapi_tool/auth/auth_helpers.ts:278
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.