CRED-2150: Add PAT auth support to Rust API client#1310
Open
CRED-2150: Add PAT auth support to Rust API client#1310
Conversation
This was referenced Mar 4, 2026
Open
28a2654 to
4c42418
Compare
0849931 to
8013ba4
Compare
5605e45 to
844fd9c
Compare
2 tasks
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
Add Personal Access Token (PAT) authentication support to the Rust API client (CRED-2150). PATs allow authenticating via an
Authorization: Bearer <PAT>header, providing an alternative to the traditionalDD-API-KEY+DD-APPLICATION-KEYheader pair.Behavior
DD_BEARER_TOKENis set (orset_pat()is called), theAuthorization: Bearer <token>header is sent alongside any configured API key and app key headers.DD_BEARER_TOKENaligns with the OpenAPI spec'sbearerAuthsecurity scheme (x-env-name: DD_BEARER_TOKEN).Commit structure
This PR has 2 commits for easier review:
CRED-2150: Add PAT auth support - templates and tests— Template changes (.generator/src/generator/templates/*.j2) + integration tests (tests/configuration_test.rs). Review this commit.CRED-2150: Regenerated client code from templates— All generated files insrc/(132 files). Large diff produced by the generator — can skip review.Summary of changes
api.j2,configuration.j2): Bearer auth support is spec-driven — conditioned onbearerAuthbeing present in the OpenAPIsecuritySchemes, with the env var name read fromx-env-name. No hardcoded env var names.Configurationstruct (src/datadog/configuration.rs): Addedpat: Option<String>field,set_pat()method, andauth_headers()method that returns all configured auth headers (bearer + API key + app key).configuration.auth_headers()call.DD_BEARER_TOKENenv var: When set to a non-empty value, the bearer token is included in requests. An empty value is ignored.configuration.rstotests/configuration_test.rsso they survive regeneration.Test plan
set_pat(),auth_headers(), env var handling, and coexistence of bearer + API key authapi.datad0g.com) usingAuthorization: Bearerwith a real PATPR Stack
API Client Libraries
OpenAPI Spec Changes