feat(go): add OAuth client credentials support with automatic token refresh #11106
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.
Description
Refs: Requested by @tjb9dc via Slack
Implements OAuth client credentials authentication in the Go SDK generator with automatic token refresh support, addressing the TODO at
EndpointSnippetGenerator.ts#L335-L337.Link to Devin run: https://app.devin.ai/sessions/cbaf1544965b49c2a2eef83a22b1b199
Changes Made
OAuthTokenProviderincore/oauth.gothat manages OAuth tokens with:sync.MutexWriteRequestOptionsDefinitionto addClientID,ClientSecret, and internalOAuthTokenProviderfields toRequestOptionsClientCredentialsOptionstruct andWithClientCredentials(clientID, clientSecret)option function for a cleaner user-facing APIcomputeOAuthClientCredentialsConfigfunction to extract OAuth configuration from IR auth-schemesEndpointSnippetGenerator.tsto generateWithClientCredentialsconstructor arguments instead of warningUpdates Since Last Revision
Addressed PR feedback to auto-generate OAuth token refresh from auth-schemes config:
OAuthClientCredentialsConfigstruct to hold OAuth endpoint configuration extracted from IRcomputeOAuthClientCredentialsConfigfunction that extracts token endpoint, request/response field names from IRWriteClientto accept OAuth config and generate token provider initialization codeoauth-client-credentials-defaultnow useWithClientCredentials(clientID, clientSecret)instead ofWithOAuthTokenProviderTesting
oauth-client-credentials-defaultfixtureoauth-client-credentials-environment-variablesfixturepnpm run check)Human Review Checklist
oauth-client-credentials-environment-variablesstill showsWithOAuthTokenProviderin dynamic snippets whileoauth-client-credentials-defaultusesWithClientCredentials- verify this is expected or needs fixingcomputeOAuthClientCredentialsConfighas many early return points that returnnil- verify the function correctly extracts config for all OAuth fixturesGetToken()reads fields without lock - verify the double-check pattern is sufficientExpiresIn< 120 seconds, expiry time could be in the past immediately