Skip to content

Commit 32f5027

Browse files
fix(python): Remove oauth-token-override config flag (#11113)
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. - Remove oauth_token_override field from SDKCustomConfig - Update root_client_generator.py to always enable token override for OAuth - Update readme_snippet_builder.py to detect OAuth from IR instead of config - Remove token-override seed fixtures (now merged with no-custom-config) - Regenerate seed output for oauth-client-credentials fixtures Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 8eb7426 commit 32f5027

File tree

271 files changed

+95
-10870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+95
-10870
lines changed

generators/python/sdk/versions.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
22
# For unreleased changes, use unreleased.yml
3+
- version: 4.44.1
4+
changelogEntry:
5+
- summary: |
6+
Remove `oauth-token-override` config flag. OAuth token override is now always enabled for OAuth client
7+
credentials flows, allowing users to authenticate with either client_id/client_secret OR a pre-generated
8+
bearer token directly via the `token` parameter without any configuration.
9+
type: fix
10+
createdAt: "2025-12-09"
11+
irVersion: 61
12+
313
- version: 4.44.0
414
changelogEntry:
515
- summary: |

generators/python/src/fern_python/generator_cli/generator_cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ def generate_readme(
9696
github_installation_token: Optional[str] = None,
9797
pagination_enabled: Union[bool, None] = False,
9898
websocket_enabled: bool = False,
99-
oauth_token_override: bool = False,
10099
) -> str:
101100
readme_snippet_builder = ReadmeSnippetBuilder(
102101
ir=self._ir,
103102
package_name=self._package_name,
104103
snippets=snippets,
105104
pagination_enabled=pagination_enabled,
106105
websocket_enabled=websocket_enabled,
107-
oauth_token_override=oauth_token_override,
108106
generated_root_client=generated_root_client,
109107
api_error_reference=self._context.core_utilities.get_reference_to_api_error(as_snippet=True),
110108
endpoint_metadata=self._endpoint_metadata,

generators/python/src/fern_python/generator_cli/readme_snippet_builder.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def __init__(
4444
source_file_factory: SourceFileFactory,
4545
pagination_enabled: Optional[bool] = False,
4646
websocket_enabled: Optional[bool] = False,
47-
oauth_token_override: Optional[bool] = False,
4847
):
4948
self._ir = ir
5049
self._package_name = package_name
@@ -54,7 +53,8 @@ def __init__(
5453
# flags and how many places need this context.
5554
self._pagination_enabled = pagination_enabled
5655
self._websocket_enabled = websocket_enabled
57-
self._oauth_token_override = oauth_token_override
56+
# Determine if OAuth client credentials is enabled from the IR
57+
self._is_oauth_client_credentials = self._check_oauth_client_credentials(ir)
5858

5959
self._source_file_factory = source_file_factory
6060

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

87-
if self._oauth_token_override:
87+
if self._is_oauth_client_credentials:
8888
snippets[ReadmeSnippetBuilder.OAUTH_TOKEN_OVERRIDE_FEATURE_ID] = self._build_oauth_token_override_snippets()
8989

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

548+
def _check_oauth_client_credentials(self, ir: ir_types.IntermediateRepresentation) -> bool:
549+
"""Check if OAuth client credentials is configured in the IR."""
550+
if ir.auth is None:
551+
return False
552+
for scheme in ir.auth.schemes:
553+
scheme_union = scheme.get_as_union()
554+
if scheme_union.type == "oauth":
555+
oauth_config = scheme_union.configuration.get_as_union()
556+
if oauth_config.type == "clientCredentials":
557+
return True
558+
return False
559+
548560
def _build_endpoint_feature_map(
549561
self, ir: ir_types.IntermediateRepresentation
550562
) -> Dict[generatorcli.feature.FeatureId, List[ir_types.EndpointId]]:

generators/python/src/fern_python/generators/sdk/client_generator/root_client_generator.py

Lines changed: 66 additions & 151 deletions
Large diffs are not rendered by default.

generators/python/src/fern_python/generators/sdk/custom_config.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ class SDKCustomConfig(pydantic.BaseModel):
127127

128128
custom_pager_name: Optional[str] = None
129129

130-
# When enabled for OAuth client credentials, allows users to provide
131-
# either client_id/client_secret OR a pre-generated token directly.
132-
oauth_token_override: bool = False
133-
134130
class Config:
135131
extra = pydantic.Extra.forbid
136132

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

146140
obj = super().parse_obj(obj)
147141

generators/python/src/fern_python/generators/sdk/sdk_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def _write_readme(
624624
pagination_enabled=context.generator_config.generate_paginated_clients,
625625
websocket_enabled=write_websocket_snippets,
626626
generated_root_client=generated_root_client,
627-
oauth_token_override=context.custom_config.oauth_token_override,
628627
)
629628
project.add_file(
630629
os.path.join(

generators/python/tests/sdk/test_root_client_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_generated_root_client_builder_instantiations_list() -> None:
9292
builder = _create_test_builder()
9393
generated_root_client = builder.build()
9494

95-
# Without oauth_token_override, there should be exactly one instantiation
95+
# Without OAuth client credentials, there should be exactly one instantiation
9696
assert len(generated_root_client.sync_instantiations) == 1
9797
assert len(generated_root_client.async_instantiations) == 1
9898

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

108108

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

114-
# With oauth_token_override, there should be two instantiations
114+
# With OAuth client credentials, there should be two instantiations
115115
assert len(generated_root_client.sync_instantiations) == 2
116116
assert len(generated_root_client.async_instantiations) == 2
117117

seed/python-sdk/oauth-client-credentials-environment-variables/no-custom-config/.fern/metadata.json renamed to seed/python-sdk/oauth-client-credentials-environment-variables/.fern/metadata.json

File renamed without changes.

seed/python-sdk/oauth-client-credentials-environment-variables/no-custom-config/.github/workflows/ci.yml renamed to seed/python-sdk/oauth-client-credentials-environment-variables/.github/workflows/ci.yml

File renamed without changes.

seed/python-sdk/oauth-client-credentials-environment-variables/no-custom-config/.gitignore renamed to seed/python-sdk/oauth-client-credentials-environment-variables/.gitignore

File renamed without changes.

0 commit comments

Comments
 (0)