MCPcopy Create free account
hub / github.com/cli/cli / tokenRefresherHttpClientFunc

Function tokenRefresherHttpClientFunc

pkg/cmd/factory/default.go:225–243  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
225func 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
245func plainHttpClientFunc(ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) {
246 return func() (*http.Client, error) {

Callers 2

NewFunction · 0.85

Calls 4

ConfigFunction · 0.92
NewHTTPClientFunction · 0.92
ValueMethod · 0.80
ColorEnabledMethod · 0.80

Tested by 1