Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions generators/python/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
# For unreleased changes, use unreleased.yml
- version: 4.44.1
changelogEntry:
- summary: |
Remove `oauth-token-override` config flag. OAuth token override is now always enabled for OAuth client
credentials flows, allowing users to authenticate with either client_id/client_secret OR a pre-generated
bearer token directly via the `token` parameter without any configuration.
type: fix
createdAt: "2025-12-09"
irVersion: 61

- version: 4.44.0
changelogEntry:
- summary: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,13 @@ def generate_readme(
github_installation_token: Optional[str] = None,
pagination_enabled: Union[bool, None] = False,
websocket_enabled: bool = False,
oauth_token_override: bool = False,
) -> str:
readme_snippet_builder = ReadmeSnippetBuilder(
ir=self._ir,
package_name=self._package_name,
snippets=snippets,
pagination_enabled=pagination_enabled,
websocket_enabled=websocket_enabled,
oauth_token_override=oauth_token_override,
generated_root_client=generated_root_client,
api_error_reference=self._context.core_utilities.get_reference_to_api_error(as_snippet=True),
endpoint_metadata=self._endpoint_metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(
source_file_factory: SourceFileFactory,
pagination_enabled: Optional[bool] = False,
websocket_enabled: Optional[bool] = False,
oauth_token_override: Optional[bool] = False,
):
self._ir = ir
self._package_name = package_name
Expand All @@ -54,7 +53,8 @@ def __init__(
# flags and how many places need this context.
self._pagination_enabled = pagination_enabled
self._websocket_enabled = websocket_enabled
self._oauth_token_override = oauth_token_override
# Determine if OAuth client credentials is enabled from the IR
self._is_oauth_client_credentials = self._check_oauth_client_credentials(ir)

self._source_file_factory = source_file_factory

Expand Down Expand Up @@ -84,7 +84,7 @@ def build_readme_snippets(self) -> Dict[generatorcli.feature.FeatureId, List[str
if self._websocket_enabled:
snippets[ReadmeSnippetBuilder.WEBSOCKETS_FEATURE_ID] = self._build_websocket_snippets()

if self._oauth_token_override:
if self._is_oauth_client_credentials:
snippets[ReadmeSnippetBuilder.OAUTH_TOKEN_OVERRIDE_FEATURE_ID] = self._build_oauth_token_override_snippets()

snippets[ReadmeSnippetBuilder.ACCESS_RAW_RESPONSE_DATA_FEATURE_ID] = (
Expand Down Expand Up @@ -545,6 +545,18 @@ def _client_writer_credentials(writer: AST.NodeWriter) -> None:
print(f"Failed to generate oauth token override snippets with exception {e}")
return []

def _check_oauth_client_credentials(self, ir: ir_types.IntermediateRepresentation) -> bool:
"""Check if OAuth client credentials is configured in the IR."""
if ir.auth is None:
return False
for scheme in ir.auth.schemes:
scheme_union = scheme.get_as_union()
if scheme_union.type == "oauth":
oauth_config = scheme_union.configuration.get_as_union()
if oauth_config.type == "clientCredentials":
return True
return False

def _build_endpoint_feature_map(
self, ir: ir_types.IntermediateRepresentation
) -> Dict[generatorcli.feature.FeatureId, List[ir_types.EndpointId]]:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ class SDKCustomConfig(pydantic.BaseModel):

custom_pager_name: Optional[str] = None

# When enabled for OAuth client credentials, allows users to provide
# either client_id/client_secret OR a pre-generated token directly.
oauth_token_override: bool = False

class Config:
extra = pydantic.Extra.forbid

Expand All @@ -140,8 +136,6 @@ def parse_obj(cls, obj: Any) -> "SDKCustomConfig":
obj = obj.copy()
if "custom-pager-name" in obj and "custom_pager_name" not in obj:
obj["custom_pager_name"] = obj.pop("custom-pager-name")
if "oauth-token-override" in obj and "oauth_token_override" not in obj:
obj["oauth_token_override"] = obj.pop("oauth-token-override")

obj = super().parse_obj(obj)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ def _write_readme(
pagination_enabled=context.generator_config.generate_paginated_clients,
websocket_enabled=write_websocket_snippets,
generated_root_client=generated_root_client,
oauth_token_override=context.custom_config.oauth_token_override,
)
project.add_file(
os.path.join(
Expand Down
8 changes: 4 additions & 4 deletions generators/python/tests/sdk/test_root_client_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_generated_root_client_builder_instantiations_list() -> None:
builder = _create_test_builder()
generated_root_client = builder.build()

# Without oauth_token_override, there should be exactly one instantiation
# Without OAuth client credentials, there should be exactly one instantiation
assert len(generated_root_client.sync_instantiations) == 1
assert len(generated_root_client.async_instantiations) == 1

Expand All @@ -106,12 +106,12 @@ def test_generated_root_client_builder_instantiations_list() -> None:
assert snippet_from_property.to_str() == snippet_from_list.to_str()


def test_generated_root_client_builder_with_oauth_token_override() -> None:
"""Test that oauth_token_override adds a second token-based instantiation."""
def test_generated_root_client_builder_with_oauth_client_credentials() -> None:
"""Test that OAuth client credentials adds a second token-based instantiation."""
builder = _create_test_builder(oauth_token_override=True)
generated_root_client = builder.build()

# With oauth_token_override, there should be two instantiations
# With OAuth client credentials, there should be two instantiations
assert len(generated_root_client.sync_instantiations) == 2
assert len(generated_root_client.async_instantiations) == 2

Expand Down

This file was deleted.

Loading
Loading