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

Method TokenForUserWithRefresh

internal/config/config.go:784–793  ·  view source on GitHub ↗

TokenForUserWithRefresh retrieves the credential for a specified user and hostname and, when it is refreshable and its access token is expiring, renews and persists it, returning the credential to use and the refresh outcome. Non-refreshable credentials are returned unchanged with RefreshStatusInapp

(hostname, username string)

Source from the content-addressed store, hash-verified

782// its access token is expiring, renews and persists it, returning the credential to use and the refresh outcome.
783// Non-refreshable credentials are returned unchanged with RefreshStatusInapplicable.
784func (c *AuthConfig) TokenForUserWithRefresh(hostname, username string) (gh.Credential, gh.RefreshStatus, error) {
785 credential, err := c.TokenForUser(hostname, username)
786 if err != nil {
787 return credential, gh.RefreshStatusInapplicable, err
788 }
789 if !credential.IsRefreshable() {
790 return credential, gh.RefreshStatusInapplicable, nil
791 }
792 return c.refreshCredentialForUser(hostname, username, credential)
793}
794
795func keyringServiceName(hostname string) string {
796 return "gh:" + hostname

Callers

nothing calls this directly

Calls 3

TokenForUserMethod · 0.95
IsRefreshableMethod · 0.80

Tested by

no test coverage detected