function createBearerAuthInterceptor
Since 0.1.0
createBearerAuthInterceptor(token: string | (() => Promise<string>)): ClientRequestInterceptor

Create a request interceptor that sets Authorization: Bearer <token>.

Accepts a static token or an async provider. The header is only set when the request does not already carry an authorization header, allowing per-endpoint credential override.

Parameters

token: string | (() => Promise<string>)

Static bearer token or async provider returning one.

Return Type

A request interceptor.

Usage

import { createBearerAuthInterceptor } from "sdk/src/index.ts";