getTokenWithRefresh resolves the active token for the hostname and optional username and refreshes it when necessary. Refresh is best effort: a failed refresh still yields the last stored token, and an empty result is left for the caller to handle.
(authCfg gh.AuthConfig, hostname, username string)
| 191 | // necessary. Refresh is best effort: a failed refresh still yields the last stored token, and an empty result is |
| 192 | // left for the caller to handle. |
| 193 | func getTokenWithRefresh(authCfg gh.AuthConfig, hostname, username string) (gh.Credential, gh.RefreshStatus) { |
| 194 | if username == "" { |
| 195 | cred, status, _ := authCfg.ActiveTokenWithRefresh(hostname) |
| 196 | return cred, status |
| 197 | } |
| 198 | cred, status, _ := authCfg.TokenForUserWithRefresh(hostname, username) |
| 199 | return cred, status |
| 200 | } |
| 201 | |
| 202 | // getNonRefreshableTokenFromKeyring reads the token straight from secure storage for the hostname and optional |
| 203 | // username, consulting no environment variable or config entry. |
no test coverage detected