[Internal] Resolve token_audience from token_federation_default_oidc_audiences in host metadata#1387
Open
[Internal] Resolve token_audience from token_federation_default_oidc_audiences in host metadata#1387
Conversation
…dc_audiences Read the token_federation_default_oidc_audiences list from the well-known discovery endpoint and use the first element as the token_audience when not explicitly configured. Falls back to account_id for account-level hosts without workspace_id. Co-authored-by: Isaac
Revert black-style imports back to the project's continuation-line indent style used by yapf/isort. Co-authored-by: Isaac
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
hectorcast-db
approved these changes
Apr 14, 2026
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.
Summary
Read the
token_federation_default_oidc_audienceslist from the/.well-known/databricks-configdiscovery endpoint and use the first element as thetoken_audiencewhen not explicitly configured. This removes the need for explicit audience configuration and replaces the TODO for adding an explicit audience to the metadata endpoint.Why
Today, the SDK resolves the OIDC token audience through a fallback chain: an explicitly configured
token_audience, or for account-level hosts, theaccount_id. There was a TODO in the code to add explicit audience support from the metadata discovery endpoint.The discovery endpoint now returns a
token_federation_default_oidc_audiencesfield (a list of audience strings). This PR reads that field and uses it as the primary source fortoken_audience, which is more reliable than theaccount_idheuristic and works correctly for all host types (workspace, account, unified).What changed
Interface changes
HostMetadata.token_federation_default_oidc_audiences: Optional[List[str]]— New field on theHostMetadatadataclass, parsed from the discovery endpoint response. Included infrom_dict()andas_dict().Behavioral changes
token_audienceis not explicitly configured andtoken_federation_default_oidc_audiencesis present in host metadata, the SDK now setstoken_audienceto the first element of that list.account_idfallback (which only applies to account hosts withoutworkspace_id).token_audienceis never overwritten.Internal changes
# TODO: Add explicit audience to the metadata discovery endpoint.comment (now implemented).How is this tested?
4 new unit tests in
tests/test_config.py:token_federation_default_oidc_audiencessetstoken_audience(first element) when not explicitly configured.token_federation_default_oidc_audiencestakes priority over theaccount_idfallback for account hosts.token_audienceis not overwritten bytoken_federation_default_oidc_audiences.account_idwhentoken_federation_default_oidc_audiencesis absent and noworkspace_id.