CRED-2146: Add PAT auth support to Python API client#3243
Draft
CRED-2146: Add PAT auth support to Python API client#3243
Conversation
This was referenced Mar 4, 2026
Draft
36432fc to
fd911c2
Compare
fd911c2 to
8374703
Compare
8374703 to
fe5c4e4
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
Add Personal Access Token (PAT) authentication support to the Python API client. PATs authenticate via an
Authorization: Bearer <PAT>header. This is in addition to (not replacing) the existing API key + app key auth — both can be sent simultaneously.Behavior
DD_BEARER_TOKENenv var or passaccess_token=toConfiguration()to configure PAT authAuthorization: Bearer <token>header is sent alongside any configuredDD-API-KEYandDD-APPLICATION-KEYheadersbearerAuthsecurity scheme now defined in the OpenAPI spec (x-env-name: DD_BEARER_TOKEN)Summary of changes
configuration.j2/configuration.py: Uncommented the existing bearer auth handler in the template so the generator picks upbearerAuthfrom the OpenAPI spec automatically. Uses the standardaccess_tokenfield. AddedDD_BEARER_TOKENenv var loading.api_client.j2/api_client.py: No special branching for bearer auth — all configured auth headers flow through the regular auth loop.tests/test_pat_auth.py: Unit tests covering configuration, auth settings, env var loading, and header behavior (all headers sent together, bearer-only, api-keys-only, endpoint without bearerAuth).Test plan
python -m pytest tests/test_pat_auth.py -v)bearerAuthin auth list don't send Authorization headerPR Stack
API Client Libraries
OpenAPI Spec Changes