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

Function tokenRefresherHttpClientFunc

pkg/cmd/factory/default.go:226–244  ·  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

224// round trip, so a verbose trace would interleave the refresh traffic in the middle of the request trace the user is
225// actually inspecting. Auth flows that should surface their own full traffic use f.PlainHttpClient instead.
226func tokenRefresherHttpClientFunc(ios *iostreams.IOStreams, appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) {
227 return func() (*http.Client, error) {
228 logHeadlineOnly := true
229 if verbose, ok := debug.Config().VerboseTokenRefresh.Value(); ok {
230 logHeadlineOnly = !verbose
231 }
232 opts := api.HTTPClientOptions{
233 Log: ios.ErrOut,
234 LogColorize: ios.ColorEnabled(),
235 LogHeadlineOnly: logHeadlineOnly,
236 AppVersion: appVersion,
237 InvokingAgent: invokingAgent,
238 // This is required to prevent automatic setting of auth and other headers.
239 SkipDefaultHeaders: true,
240 TelemetryDisabler: telemetryDisabler,
241 }
242 return api.NewHTTPClient(opts)
243 }
244}
245
246func oauthAppHttpClientFunc(appVersion string, invokingAgent string, telemetryDisabler ghtelemetry.Disabler) func() (*http.Client, error) {
247 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