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

Function getTokenReadOnly

pkg/cmd/auth/token/token.go:182–188  ·  view source on GitHub ↗

getTokenReadOnly resolves the stored active token for the hostname and optional username without contacting the token endpoint. It still surfaces a refreshable credential's stored access token, so an expiring token is returned, just not refreshed.

(authCfg gh.AuthConfig, hostname, username string)

Source from the content-addressed store, hash-verified

180// token endpoint. It still surfaces a refreshable credential's stored access token, so an expiring token is
181// returned, just not refreshed.
182func getTokenReadOnly(authCfg gh.AuthConfig, hostname, username string) gh.Credential {
183 if username == "" {
184 return authCfg.ActiveToken(hostname)
185 }
186 cred, _ := authCfg.TokenForUser(hostname, username)
187 return cred
188}
189
190// getTokenWithRefresh resolves the active token for the hostname and optional username and refreshes it when
191// necessary. Refresh is best effort: a failed refresh still yields the last stored token, and an empty result is

Callers 1

tokenRunFunction · 0.85

Calls 2

ActiveTokenMethod · 0.65
TokenForUserMethod · 0.65

Tested by

no test coverage detected