resolveCredential returns the credential gh should present for the host and optional user (an empty username means the active account), refreshing an expiring token unless noRefresh is set. Refresh is best effort: a failed refresh yields the last stored credential, which the caller still validates v
(authCfg gh.AuthConfig, hostname, username string, noRefresh bool)
| 538 | // refresh yields the last stored credential, which the caller still validates via the scope check. The returned status |
| 539 | // reports whether a refresh happened. |
| 540 | func resolveCredential(authCfg gh.AuthConfig, hostname, username string, noRefresh bool) (gh.Credential, gh.RefreshStatus) { |
| 541 | if noRefresh { |
| 542 | if username == "" { |
| 543 | return authCfg.ActiveToken(hostname), gh.RefreshStatusInapplicable |
| 544 | } |
| 545 | credential, _ := authCfg.TokenForUser(hostname, username) |
| 546 | return credential, gh.RefreshStatusInapplicable |
| 547 | } |
| 548 | if username == "" { |
| 549 | credential, status, _ := authCfg.ActiveTokenWithRefresh(hostname) |
| 550 | return credential, status |
| 551 | } |
| 552 | credential, status, _ := authCfg.TokenForUserWithRefresh(hostname, username) |
| 553 | return credential, status |
| 554 | } |
no test coverage detected