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