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

Method TokenForUserWithRefresh

internal/config/config.go:735–744  ·  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

733// its access token is expiring, renews and persists it, returning the credential to use and the refresh outcome.
734// Non-refreshable credentials are returned unchanged with RefreshStatusInapplicable.
735func (c *AuthConfig) TokenForUserWithRefresh(hostname, username string) (gh.Credential, gh.RefreshStatus, error) {
736 credential, err := c.TokenForUser(hostname, username)
737 if err != nil {
738 return credential, gh.RefreshStatusInapplicable, err
739 }
740 if !credential.IsRefreshable() {
741 return credential, gh.RefreshStatusInapplicable, nil
742 }
743 return c.refreshCredentialForUser(hostname, username, credential)
744}
745
746func keyringServiceName(hostname string) string {
747 return "gh:" + hostname

Callers

nothing calls this directly

Calls 3

TokenForUserMethod · 0.95
IsRefreshableMethod · 0.80

Tested by

no test coverage detected