Skip to content

Commit

Permalink
set the http client for token refresh (#137)
Browse files Browse the repository at this point in the history
missed that oauth2 library doesn't use the transport but rather gets the
http client from context. so here we're setting the context.

Signed-off-by: Mike Mason <mimason@equinix.com>
  • Loading branch information
mikemrm authored Aug 11, 2023
1 parent f9ec4d4 commit 3955331
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions oauth2x/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func NewClientCredentialsTokenSrc(ctx context.Context, cfg Config) (oauth2.Token
return nil, err
}

// If no client has already been defined, set the http client to the default otelhttp client.
if _, ok := ctx.Value(oauth2.HTTPClient).(*http.Client); !ok {
ctx = context.WithValue(ctx, oauth2.HTTPClient, otelhttp.DefaultClient)
}

ccCfg := clientcredentials.Config{
ClientID: cfg.ID,
ClientSecret: cfg.Secret,
Expand Down

0 comments on commit 3955331

Please sign in to comment.