MCPcopy
hub / github.com/cli/cli / TokenFromKeyringForUser

Method TokenFromKeyringForUser

internal/config/config.go:309–315  ·  view source on GitHub ↗

TokenFromKeyringForUser will retrieve the auth token for the given hostname and username, only searching in encrypted storage. An empty username will return an error because the potential to return the currently active token under surprising cases is just too high to risk compared to the utility of

(hostname, username string)

Source from the content-addressed store, hash-verified

307// the currently active token under surprising cases is just too high to risk
308// compared to the utility of having the function being smart.
309func (c *AuthConfig) TokenFromKeyringForUser(hostname, username string) (string, error) {
310 if username == "" {
311 return "", errors.New("username cannot be blank")
312 }
313
314 return keyring.Get(keyringServiceName(hostname), username)
315}
316
317// ActiveUser will retrieve the username for the active user at the given hostname.
318// This will not be accurate if the oauth token is set from an environment variable.

Callers 1

ActiveTokenMethod · 0.95

Calls 2

GetFunction · 0.92
keyringServiceNameFunction · 0.70

Tested by

no test coverage detected