| 196 | } |
| 197 | |
| 198 | func HttpClientFunc(cfgFunc func() (gh.Config, error), ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) { |
| 199 | return func() (*http.Client, error) { |
| 200 | cfg, err := cfgFunc() |
| 201 | if err != nil { |
| 202 | return nil, err |
| 203 | } |
| 204 | opts := api.HTTPClientOptions{ |
| 205 | RefreshingConfig: cfg.Authentication(), |
| 206 | Log: ios.ErrOut, |
| 207 | LogColorize: ios.ColorEnabled(), |
| 208 | AppVersion: appVersion, |
| 209 | InvokingAgent: invokingAgent, |
| 210 | TelemetryDisabler: telemetryDisabler, |
| 211 | } |
| 212 | client, err := api.NewHTTPClient(opts) |
| 213 | if err != nil { |
| 214 | return nil, err |
| 215 | } |
| 216 | client.Transport = api.ExtractHeader("X-GitHub-SSO", &ssoHeader)(client.Transport) |
| 217 | return client, nil |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // tokenRefresherHttpClientFunc builds the HTTP client used to renew OAuth tokens. It mirrors plainHttpClientFunc but |
| 222 | // defaults to headline-only logging so that, under GH_DEBUG=api, the refresh exchange does not produce a |