diff --git a/src/autoscaler/cf/client.go b/src/autoscaler/cf/client.go index a16a453608..dceb8dd3b8 100644 --- a/src/autoscaler/cf/client.go +++ b/src/autoscaler/cf/client.go @@ -320,7 +320,8 @@ func (c *CtxClient) introspectToken(ctx context.Context, token string) (*Introsp if err != nil { return nil, err } - request.SetBasicAuth(c.conf.ClientID, c.conf.Secret) + + c.addAuth(ctx, request) request.Header.Set("Content-Type", "application/x-www-form-urlencoded;charset=utf-8") resp, err := c.Client.Do(request) @@ -345,3 +346,13 @@ func (c *CtxClient) introspectToken(ctx context.Context, token string) (*Introsp return introspectionResponse, nil } + +func (c *CtxClient) addAuth(ctx context.Context, req *http.Request) error { + tokens, err := c.GetTokens(ctx) + if err != nil { + return fmt.Errorf("get token failed: %w", err) + } + + req.Header.Set("Authorization", TokenTypeBearer+" "+tokens.AccessToken) + return nil +}