| 334 | } |
| 335 | |
| 336 | func authRecoveryCommand(cfg gh.Config, httpErr api.HTTPError) string { |
| 337 | if httpErr.RequestURL == nil { |
| 338 | return "gh auth login" |
| 339 | } |
| 340 | |
| 341 | hostname := ghauth.NormalizeHostname(httpErr.RequestURL.Hostname()) |
| 342 | cred := cfg.Authentication().ActiveToken(hostname) |
| 343 | if shared.AuthTokenRefreshable(cred.Token, cred.Source) { |
| 344 | return fmt.Sprintf("gh auth refresh -h %s", hostname) |
| 345 | } |
| 346 | |
| 347 | return fmt.Sprintf("gh auth login -h %s", hostname) |
| 348 | } |
| 349 | |
| 350 | // printAuthWarnings writes each warning recorded by authCfg to w, prefixed with a warning icon. |
| 351 | func printAuthWarnings(w io.Writer, cs *iostreams.ColorScheme, authCfg gh.AuthConfig) { |