ActiveTokenWithRefresh retrieves the active credential for the given hostname and, when it is refreshable and its access token is expiring, renews and persists it, returning the credential to use and the refresh outcome. Non-refreshable credentials are returned unchanged with RefreshStatusInapplicab
(hostname string)
| 351 | // access token is expiring, renews and persists it, returning the credential to use and the refresh outcome. |
| 352 | // Non-refreshable credentials are returned unchanged with RefreshStatusInapplicable. |
| 353 | func (c *AuthConfig) ActiveTokenWithRefresh(hostname string) (gh.Credential, gh.RefreshStatus, error) { |
| 354 | credential := c.ActiveToken(hostname) |
| 355 | if !credential.IsRefreshable() { |
| 356 | return credential, gh.RefreshStatusInapplicable, nil |
| 357 | } |
| 358 | user, err := c.ActiveUser(hostname) |
| 359 | if err != nil { |
| 360 | // A refreshable active credential is always keyed by the active user, so this is unreachable in practice. |
| 361 | // If we somehow cannot identify the user, we have no key to refresh under, so return the credential as-is. |
| 362 | return credential, gh.RefreshStatusInapplicable, err |
| 363 | } |
| 364 | return c.refreshCredentialForUser(hostname, user, credential) |
| 365 | } |
| 366 | |
| 367 | // HasActiveToken returns true when a token for the hostname is present. |
| 368 | func (c *AuthConfig) HasActiveToken(hostname string) bool { |
nothing calls this directly
no test coverage detected