CRED-2150: Add OAuth/AuthZ bearer token support to Rust API client#1438
Closed
CRED-2150: Add OAuth/AuthZ bearer token support to Rust API client#1438
Conversation
This was referenced Mar 30, 2026
Closed
Author
|
Closing: Adding OAuth/AuthZ support to the Rust client is the right long-term approach for built-in PAT support, but we are not doing this work right now. When OAuth/AuthZ is implemented in the Rust generator in the future, PATs will work automatically (as they already do in Go, Python, TypeScript, Java, and Ruby). |
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.
PR Stack
API Client Libraries (closed)
All client libraries except Rust already support PATs via the existing OAuth/AuthZ code path. No new changes were needed.
Go: CRED-2147: Add PAT auth support to Go API client datadog-api-client-go#3764 — CRED-2147— PATs work via existing OAuth code pathPython: CRED-2146: Add PAT auth support to Python API client datadog-api-client-python#3243 — CRED-2146— PATs work via existing OAuth code pathTypeScript: CRED-2148: Add PAT auth support to TypeScript API client datadog-api-client-typescript#3588 — CRED-2148— PATs work via existing OAuth code pathTypeScript v2: CRED-2148: Add PAT auth support to TypeScript v2 API client datadog-api-client-typescript#3610 — CRED-2148— PATs work via existing OAuth code pathJava: CRED-2149: Add PAT auth support to Java API client datadog-api-client-java#3555 — CRED-2149— PATs work via existing OAuth code pathRuby: CRED-2151: Add PAT auth support to Ruby API client datadog-api-client-ruby#3058 — CRED-2151— PATs work via existing OAuth code pathRust: The Rust client generator does not support OAuth/AuthZ, so PATs cannot be used through the client library today. When OAuth/AuthZ support is added to the Rust generator in the future (#1438 has the approach), PATs will work automatically.
OpenAPI Spec Changes
Why
All other Datadog API client libraries (Go, Python, TypeScript, Java, Ruby) support the
AuthZOAuth2 security scheme defined in the OpenAPI spec, which sendsAuthorization: Bearer <token>. The Rust client generator templates only handledtype: apiKeyschemes and silently skippedtype: oauth2(AuthZ). This PR adds OAuth2/AuthZ bearer token support to bring the Rust client to parity with other clients.Commit structure
CRED-2150: Add OAuth/AuthZ bearer token support - templates— Template changes + tests (review this commit)CRED-2150: Regenerated client code from templates— Generated code (137 files, can skip review)Summary of changes
Configurationstruct: Addedaccess_token: Option<String>field andset_access_token()method, matching the pattern in Go (ContextAccessToken) and Python (Configuration.access_token)api.j2template: For endpoints that listAuthZ(typeoauth2) in their security schemes, generated code now checksaccess_tokenfirst. If set, sendsAuthorization: Bearer <token>. Otherwise falls back to API key auth (DD-API-KEY+DD-APPLICATION-KEY)configuration.j2template: Addedaccess_tokenfield, setter, and initializationtests/oauth_auth_test.rsverifying the public APIHow it works
Test plan
cargo test --test oauth_auth_test)cargo check)set_access_token()— 200 OK, users returned