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

Method setRefreshableInConfig

internal/config/refreshable.go:341–360  ·  view source on GitHub ↗
(hostname, username string, credential gh.Credential)

Source from the content-addressed store, hash-verified

339}
340
341func (c *AuthConfig) setRefreshableInConfig(hostname, username string, credential gh.Credential) {
342 path := refreshablePath(hostname, username)
343 // Clear the mapping first so an omitted field does not retain a stale value.
344 _ = c.cfg.Remove(path)
345 record := normalizeToUTC(recordFromCredential(credential))
346 c.cfg.Set(append(path, "access_token"), record.AccessToken)
347 c.cfg.Set(append(path, "refresh_token"), record.RefreshToken)
348 if record.ExpiresIn != 0 {
349 c.cfg.Set(append(path, "expires_in"), strconv.Itoa(record.ExpiresIn))
350 }
351 if record.ExpiresAt != nil {
352 c.cfg.Set(append(path, "expires_at"), record.ExpiresAt.Format(time.RFC3339Nano))
353 }
354 if record.RefreshTokenExpiresIn != 0 {
355 c.cfg.Set(append(path, "refresh_token_expires_in"), strconv.Itoa(record.RefreshTokenExpiresIn))
356 }
357 if record.RefreshTokenExpiresAt != nil {
358 c.cfg.Set(append(path, "refresh_token_expires_at"), record.RefreshTokenExpiresAt.Format(time.RFC3339Nano))
359 }
360}
361
362// refreshExpiryLeeway is how far ahead of an access token's expiry gh proactively refreshes it, so a token
363// on the verge of expiring is renewed before it can fail an in-flight request.

Callers 2

loginRefreshableMethod · 0.95

Calls 5

refreshablePathFunction · 0.85
normalizeToUTCFunction · 0.85
recordFromCredentialFunction · 0.85
RemoveMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected