CRED-2149: Add PAT auth support to Java API client#3555
Draft
CRED-2149: Add PAT auth support to Java API client#3555
Conversation
This was referenced Mar 4, 2026
Draft
f143b4c to
33c1e99
Compare
32c7f00 to
20d4b7c
Compare
20d4b7c to
0bbf78d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Adds Personal Access Token (PAT) authentication support to the Java API client. PATs can be used via the
Authorization: Bearer <PAT>header, providing an alternative authentication method alongside API key + app key auth.Jira: CRED-2149
Summary
DD_BEARER_TOKEN-- when set, the client sendsAuthorization: Bearer <token>on every requestDD-API-KEY,DD-APPLICATION-KEY,Authorization: Bearer), and the server uses whichever is validApiClient.j2): Added spec-driven support fortype: httpsecurity schemes. Readsx-env-namefrom the OpenAPI spec for env var configuration. Iterates over security schemes rather than hardcoding namesApiClient.java(generated): RegistersbearerAuthin the authentication map, readsDD_BEARER_TOKENfrom the environment, and applies bearer auth alongside any other configured auth headersHttpBearerAuth(pre-existing class): AppliesAuthorization: Bearer <token>to request headersHttpBearerAuthTest: Unit tests for token get/set, header application, null-token no-op, client registration, and client set/get round-tripChanges
.generator/src/generator/templates/ApiClient.j2--httptype handler in security scheme loop, spec-driven env var reading viax-env-name, bearer auth applied alongside other auth inupdateParamsForAuth()src/main/java/com/datadog/api/client/ApiClient.java-- generated output with bearerAuth registration,DD_BEARER_TOKENenv var reading, non-exclusive auth header applicationsrc/test/java/com/datadog/api/client/auth/HttpBearerAuthTest.java-- 5 unit testsTest plan
HttpBearerAuthTest)api.datad0g.com/api/v2/current_user) withAuthorization: Bearerheader returns 200PR Stack
API Client Libraries
OpenAPI Spec Changes