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

Method TokenForUser

internal/config/config.go:559–569  ·  view source on GitHub ↗
(hostname, user string)

Source from the content-addressed store, hash-verified

557}
558
559func (c *AuthConfig) TokenForUser(hostname, user string) (string, string, error) {
560 if token, err := keyring.Get(keyringServiceName(hostname), user); err == nil {
561 return token, "keyring", nil
562 }
563
564 if token, err := c.cfg.Get([]string{hostsKey, hostname, usersKey, user, oauthTokenKey}); err == nil {
565 return token, "oauth_token", nil
566 }
567
568 return "", "default", fmt.Errorf("no token found for '%s'", user)
569}
570
571func keyringServiceName(hostname string) string {
572 return "gh:" + hostname

Callers

nothing calls this directly

Calls 4

GetFunction · 0.92
keyringServiceNameFunction · 0.70
GetMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected