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

Method TokenFromKeyringForUser

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

321// the currently active token under surprising cases is just too high to risk
322// compared to the utility of having the function being smart.
323func (c *AuthConfig) TokenFromKeyringForUser(hostname, username string) (string, error) {
324 if username == "" {
325 return "", errors.New("username cannot be blank")
326 }
327
328 return keyring.Get(keyringServiceName(hostname), username)
329}
330
331// ActiveUser will retrieve the username for the active user at the given hostname.
332// 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