Skip to content

Commit e4138fc

Browse files
committed
feat: add HTTP client option to OAuthConfig
It's already possible to customize the underlying client used by the SSE and streamable HTTP transports, but not the OAuth handler. This adds an option to customize the underlying client used by the OAuth handler.
1 parent 6d52180 commit e4138fc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

client/transport/oauth.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type OAuthConfig struct {
3434
AuthServerMetadataURL string
3535
// PKCEEnabled enables PKCE for the OAuth flow (recommended for public clients)
3636
PKCEEnabled bool
37+
// An optional HTTP client to use for requests.
38+
// If not provided, a default HTTP client will be used.
39+
HTTPClient *http.Client
3740
}
3841

3942
// TokenStore is an interface for storing and retrieving OAuth tokens.
@@ -151,10 +154,13 @@ func NewOAuthHandler(config OAuthConfig) *OAuthHandler {
151154
if config.TokenStore == nil {
152155
config.TokenStore = NewMemoryTokenStore()
153156
}
157+
if config.HTTPClient == nil {
158+
config.HTTPClient = &http.Client{Timeout: 30 * time.Second}
159+
}
154160

155161
return &OAuthHandler{
156162
config: config,
157-
httpClient: &http.Client{Timeout: 30 * time.Second},
163+
httpClient: config.HTTPClient,
158164
}
159165
}
160166

0 commit comments

Comments
 (0)