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

Method TokenFromKeyringForUser

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

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