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

Method setRefreshableInConfig

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

Source from the content-addressed store, hash-verified

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

Callers 4

loginRefreshableMethod · 0.95
TestLogoutWithCredentialFunction · 0.80

Calls 5

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

Tested by 2

TestLogoutWithCredentialFunction · 0.64