cli/cli · error · CowardlyRefusalError
couldn't find oauth token for %q: %w
Error message
couldn't find oauth token for %q: %w
What it means
Error "couldn't find oauth token for %q: %w" thrown in cli/cli.
Source
Thrown at internal/config/migration/multi_account.go:118
// so lets avoid any confusion and say there's no migration required.
if len(hostnames) == 0 {
return nil
}
// Otherwise let's get to the business of migrating!
for _, hostname := range hostnames {
tokenSource, err := getToken(c, hostname)
// If no token existed for this host we'll remove the entry from the hosts file
// by deleting it and moving on to the next one.
if errors.Is(err, noTokenError) {
// The only error that can be returned here is the key not existing, which
// we know can't be true.
_ = c.Remove(append(hostsKey, hostname))
continue
}
// For any other error we'll error out
if err != nil {
return CowardlyRefusalError{fmt.Errorf("couldn't find oauth token for %q: %w", hostname, err)}
}
username, err := getUsername(c, hostname, tokenSource.token, m.Transport)
if err != nil {
issueURL := "https://github.com/cli/cli/issues/8441"
return CowardlyRefusalError{fmt.Errorf("couldn't get user name for %q please visit %s for help: %w", hostname, issueURL, err)}
}
if err := migrateConfig(c, hostname, username); err != nil {
return CowardlyRefusalError{fmt.Errorf("couldn't migrate config for %q: %w", hostname, err)}
}
if err := migrateToken(hostname, username, tokenSource); err != nil {
return CowardlyRefusalError{fmt.Errorf("couldn't migrate oauth token for %q: %w", hostname, err)}
}
}
return nilView on GitHub (pinned to 0eeec0b92e)
Solutions
- Re-authenticate with `gh auth login` for that host so the migration can read the token, or set the token in the keyring/config manually before re-running.
When it happens
Trigger: Thrown at internal/config/migration/multi_account.go:118 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/a64dbd095dcfe6ef.
Report an issue: GitHub.