Skip to content

CRED-2148: Add PAT auth support to TypeScript API client#3588

Open
tausman wants to merge 1 commit intomasterfrom
tausman/cred-2148-typescript-pat-auth
Open

CRED-2148: Add PAT auth support to TypeScript API client#3588
tausman wants to merge 1 commit intomasterfrom
tausman/cred-2148-typescript-pat-auth

Conversation

@tausman
Copy link

@tausman tausman commented Mar 4, 2026

Why

Add support for Personal Access Token (PAT) authentication via the Authorization: Bearer <PAT> header. The OpenAPI spec now defines bearerAuth as a security scheme with x-env-name: DD_BEARER_TOKEN, and this aligns the TypeScript client with that spec.

Behavior

When DD_BEARER_TOKEN is set, the Authorization: Bearer header is sent alongside any configured API key and app key headers. Auth methods are NOT mutually exclusive — all configured headers are sent, and the server uses whichever is valid.

  • DD_API_KEY set -> DD-API-KEY header sent
  • DD_APP_KEY set -> DD-APPLICATION-KEY header sent
  • DD_BEARER_TOKEN set -> Authorization: Bearer <token> header sent
  • All three can be sent simultaneously

Summary

  • packages/datadog-api-client-common/auth.ts: Added BearerAuthAuthentication class that sets Authorization: Bearer <token> header. Added bearerAuth to AuthMethods and AuthMethodsConfiguration types, and configureAuthMethods().
  • packages/datadog-api-client-common/configuration.ts: Added DD_BEARER_TOKEN env var support in createConfiguration(). Bearer auth is applied in applySecurityAuthentication() alongside (not instead of) API key and app key auth.
  • packages/datadog-api-client-common/http/isomorphic-fetch.ts: Added redaction of Authorization header in debug logging, matching the existing pattern for DD-API-KEY and DD-APPLICATION-KEY.
  • tests/api/auth.test.ts: 10 unit tests covering bearer header application, configureAuthMethods, createConfiguration with DD_BEARER_TOKEN env var, and combined auth header behavior.

Test plan

  • 10 unit tests pass (npx jest tests/api/auth.test.ts)
  • Verified all configured auth headers are sent simultaneously
  • Verified bearer-only auth sends only Authorization: Bearer header
  • Naming aligned with OpenAPI spec: bearerAuth scheme, DD_BEARER_TOKEN env var

Generated with Claude Code


PR Stack

API Client Libraries

OpenAPI Spec Changes

@tausman tausman force-pushed the tausman/cred-2148-typescript-pat-auth branch from 2d798e4 to ed16242 Compare March 5, 2026 17:42
@tausman tausman marked this pull request as ready for review March 5, 2026 18:43
@tausman tausman requested review from a team as code owners March 5, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant