common/kafka: ability to specify OAuth scopes

This commit is contained in:
Vincent Bernat
2025-05-02 06:54:03 +02:00
parent 55b74a1954
commit a70744429a
4 changed files with 14 additions and 9 deletions

View File

@@ -19,12 +19,7 @@ type tokenProvider struct {
}
// newOAuthTokenProvider returns a sarama.AccessTokenProvider using OAuth credentials.
func newOAuthTokenProvider(ctx context.Context, tlsConfig *tls.Config, clientID, clientSecret, tokenURL string) sarama.AccessTokenProvider {
cfg := clientcredentials.Config{
ClientID: clientID,
ClientSecret: clientSecret,
TokenURL: tokenURL,
}
func newOAuthTokenProvider(ctx context.Context, tlsConfig *tls.Config, oauthConfig clientcredentials.Config) sarama.AccessTokenProvider {
httpClient := &http.Client{Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
@@ -32,7 +27,7 @@ func newOAuthTokenProvider(ctx context.Context, tlsConfig *tls.Config, clientID,
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)
return &tokenProvider{
tokenSource: cfg.TokenSource(context.Background()),
tokenSource: oauthConfig.TokenSource(context.Background()),
}
}