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)
| 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. |
| 309 | func (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. |
no test coverage detected