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

Function getTokenWithRefresh

pkg/cmd/auth/token/token.go:193–200  ·  view source on GitHub ↗

getTokenWithRefresh resolves the active token for the hostname and optional username and refreshes it when necessary. Refresh is best effort: a failed refresh still yields the last stored token, and an empty result is left for the caller to handle.

(authCfg gh.AuthConfig, hostname, username string)

Source from the content-addressed store, hash-verified

191// necessary. Refresh is best effort: a failed refresh still yields the last stored token, and an empty result is
192// left for the caller to handle.
193func getTokenWithRefresh(authCfg gh.AuthConfig, hostname, username string) (gh.Credential, gh.RefreshStatus) {
194 if username == "" {
195 cred, status, _ := authCfg.ActiveTokenWithRefresh(hostname)
196 return cred, status
197 }
198 cred, status, _ := authCfg.TokenForUserWithRefresh(hostname, username)
199 return cred, status
200}
201
202// getNonRefreshableTokenFromKeyring reads the token straight from secure storage for the hostname and optional
203// username, consulting no environment variable or config entry.

Callers 1

tokenRunFunction · 0.85

Calls 2

Tested by

no test coverage detected