-
Notifications
You must be signed in to change notification settings - Fork 271
feat(csharp): add support for inferred authentication scheme #11109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
9
commits into
main
Choose a base branch
from
devin/1765244724-csharp-inferred-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+20,171
−49
Conversation
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
Contributor
Co-Authored-By: Niels Swimberghe <[email protected]>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
… inferred auth Co-Authored-By: Niels Swimberghe <[email protected]>
Swimburger
reviewed
Dec 9, 2025
seed/csharp-sdk/websocket-inferred-auth/src/SeedWebsocketAuth/Core/InferredAuthTokenProvider.cs
Show resolved
Hide resolved
seed/csharp-sdk/websocket-inferred-auth/src/SeedWebsocketAuth/Core/InferredAuthTokenProvider.cs
Outdated
Show resolved
Hide resolved
...rp-sdk/inferred-auth-implicit/src/SeedInferredAuthImplicit/SeedInferredAuthImplicitClient.cs
Outdated
Show resolved
Hide resolved
Use PascalCase property names (XApiKey, ClientId, ClientSecret) instead of private field names (_xApiKey, _clientId, _clientSecret) when initializing the token request object in InferredAuthTokenProvider. Co-Authored-By: Niels Swimberghe <[email protected]>
- Updated the SeedInferredAuthExplicitClient, SeedInferredAuthImplicitNoExpiryClient, and SeedWebsocketAuthClient constructors to accept an optional scope parameter. - Modified example snippets and test cases to reflect the new constructor signature, ensuring consistent usage of "X-Api-Key", "client_id", "client_secret", and "scope". - Adjusted README files and code snippets to demonstrate the updated client initialization.
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.
feat(csharp): Add Inferred Authentication Support
Summary
This PR implements support for the inferred authentication scheme in the C# SDK generator. Inferred authentication is a pattern where authentication credentials are automatically obtained by calling a token endpoint (e.g., OAuth client credentials flow) before making authenticated API requests. The generator now:
InferredAuthTokenProviderclass that handles token acquisition and cachingKey Changes
Generator Implementation
New Generator Component (InferredAuthTokenProviderGenerator.ts):
InferredAuthTokenProviderclass in the Core namespaceGetAuthHeadersAsync()method with caching and expiry supportRoot Client Integration (RootClientGenerator.ts):
InferredAuthTokenProviderwith required credentialsFunc<string>) to avoid blocking constructor callsContext Updates (SdkGeneratorContext.ts):
getInferredAuth()helper method to detect inferred auth schemesGenerator Entry Point (SdkGeneratorCli.ts):
InferredAuthTokenProviderwhen inferred auth is detectedGenerated Code Updates
Seed Test Fixtures (4 fixtures updated):
inferred-auth-explicit- Explicit auth with client credentialsinferred-auth-implicit-no-expiry- No expiry trackinginferred-auth-implicit- Implicit auth with expirywebsocket-inferred-auth- WebSocket-specific inferred authEach fixture now includes:
InferredAuthTokenProviderclass (example)Mock Server Test Integration
Base Mock Server Test Generator (BaseMockServerTestGenerator.ts):
MockInferredAuthEndpointmethod to mock token responsesTechnical Implementation Details
Token Caching Strategy
The generated provider implements efficient token management:
Lazy Header Evaluation
Headers use
Func<string>to avoid blocking the client constructor:Credential Parameter Collection
The generator intelligently extracts required credentials:
Testing
All seed test fixtures have been regenerated and validated:
inferred-auth-explicit- Tests explicit client credentials flowinferred-auth-implicit- Tests implicit auth with token expiryinferred-auth-implicit-no-expiry- Tests auth without expiry trackingwebsocket-inferred-auth- Tests WebSocket-specific auth scenariosMock server tests ensure the generated code works correctly without external dependencies.
Files Changed
Generator Source (5 files)
generators/csharp/codegen/src/context/generation-info.ts- Added InferredAuthTokenProvider type referencegenerators/csharp/sdk/src/SdkGeneratorCli.ts- Added generator instantiationgenerators/csharp/sdk/src/SdkGeneratorContext.ts- Added helper methodgenerators/csharp/sdk/src/inferred-auth/InferredAuthTokenProviderGenerator.ts- New generator (337 lines)generators/csharp/sdk/src/root-client/RootClientGenerator.ts- Client integration (+264 lines)Test Infrastructure (1 file)
generators/csharp/sdk/src/test/mock-server/BaseMockServerTestGenerator.ts- Mock server supportGenerated Seed Outputs (17 files)
Version Configuration (1 file)
generators/csharp/sdk/versions.yml- Updated version metadataBreaking Changes
None. This is an additive feature that only affects SDKs using the inferred authentication scheme.
Next Steps
.Resultblocking in header suppliers