tokenRefresherHttpClientFunc builds the HTTP client used to renew OAuth tokens. It mirrors plainHttpClientFunc but defaults to headline-only logging so that, under GH_DEBUG=api, the refresh exchange does not produce a full request/response trace. A token refresh is a side-band exchange triggered fro
(ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler)
| 223 | // round trip, so a verbose trace would interleave the refresh traffic in the middle of the request trace the user is |
| 224 | // actually inspecting. Auth flows that should surface their own full traffic use f.PlainHttpClient instead. |
| 225 | func tokenRefresherHttpClientFunc(ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) { |
| 226 | return func() (*http.Client, error) { |
| 227 | logHeadlineOnly := true |
| 228 | if verbose, ok := debug.Config().VerboseTokenRefresh.Value(); ok { |
| 229 | logHeadlineOnly = !verbose |
| 230 | } |
| 231 | opts := api.HTTPClientOptions{ |
| 232 | Log: ios.ErrOut, |
| 233 | LogColorize: ios.ColorEnabled(), |
| 234 | LogHeadlineOnly: logHeadlineOnly, |
| 235 | AppVersion: appVersion, |
| 236 | InvokingAgent: invokingAgent, |
| 237 | // This is required to prevent automatic setting of auth and other headers. |
| 238 | SkipDefaultHeaders: true, |
| 239 | TelemetryDisabler: telemetryDisabler, |
| 240 | } |
| 241 | return api.NewHTTPClient(opts) |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | func plainHttpClientFunc(ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) { |
| 246 | return func() (*http.Client, error) { |