| 307 | } |
| 308 | |
| 309 | func authRecoveryCommand(cfg gh.Config, httpErr api.HTTPError) string { |
| 310 | if httpErr.RequestURL == nil { |
| 311 | return "gh auth login" |
| 312 | } |
| 313 | |
| 314 | hostname := ghauth.NormalizeHostname(httpErr.RequestURL.Hostname()) |
| 315 | cred := cfg.Authentication().ActiveToken(hostname) |
| 316 | if shared.AuthTokenRefreshable(cred.Token, cred.Source) { |
| 317 | return fmt.Sprintf("gh auth refresh -h %s", hostname) |
| 318 | } |
| 319 | |
| 320 | return fmt.Sprintf("gh auth login -h %s", hostname) |
| 321 | } |
| 322 | |
| 323 | // printAuthWarnings writes each warning recorded by authCfg to w, prefixed with a warning icon. |
| 324 | func printAuthWarnings(w io.Writer, cs *iostreams.ColorScheme, authCfg gh.AuthConfig) { |