chenhg5/cc-connect · error
--token is required (format: app_key:app_secret)
Error message
--token is required (format: app_key:app_secret)
What it means
The non-bind counterpart of [488]: resolveYuanbaoBotToken requires --token in `app_key:app_secret` format, and if the value is absent or malformed (empty, ':' at position 0, trailing ':', or no ':') outside bind mode it returns this error. Both key and secret must be non-empty for the format check to pass.
Source
Thrown at cmd/cc-connect/yuanbao.go:132
fmt.Printf("✅ Yuanbao bot configured for project %q\n", saveResult.ProjectName)
fmt.Printf(" Platform: yuanbao (projects[%d].platforms[%d])\n", saveResult.ProjectIndex, saveResult.PlatformAbsIndex)
if saveResult.AllowFrom != "" {
fmt.Printf(" allow_from: %s\n", saveResult.AllowFrom)
}
fmt.Println()
fmt.Println("Next: run cc-connect (or restart the daemon) and the platform will")
fmt.Println("auto-fetch sign-tokens via bot_token and connect over WebSocket.")
}
func resolveYuanbaoBotToken(mode, raw string) (string, error) {
token := strings.TrimSpace(raw)
idx := strings.Index(token, ":")
if token == "" || idx <= 0 || idx >= len(token)-1 {
if mode == yuanbaoSetupModeBind {
return "", fmt.Errorf("bind mode requires --token (format: app_key:app_secret)")
}
return "", fmt.Errorf("--token is required (format: app_key:app_secret)")
}
return token, nil
}
// splitYuanbaoTokenForVerify is the same split as platform/yuanbao's
// splitBotToken, inlined here so the CLI doesn't need to import internal
// helpers of the platform package.
func splitYuanbaoTokenForVerify(raw string) (appKey, appSecret string) {
raw = strings.TrimSpace(raw)
idx := strings.Index(raw, ":")
if idx <= 0 || idx >= len(raw)-1 {
return "", ""
}
return strings.TrimSpace(raw[:idx]), strings.TrimSpace(raw[idx+1:])
}
func printYuanbaoUsage() {
fmt.Println(`Usage: cc-connect yuanbao <command> [options]View on GitHub (pinned to 4000b2338a)
Solutions
- Supply --token as "app_key:app_secret" with both parts non-empty and the argument quoted
- Re-copy the token from the Yuanbao console and verify it contains a colon
- Check shell quoting/history so the full token reaches the CLI
- Consult `cc-connect setup --help` for the exact expected token format
Example fix
// before cc-connect setup yuanbao --token # omitted or "mykey" // after cc-connect setup yuanbao --token "mykey:mysecret"
Defensive patterns
Strategy: validation
Validate before calling
func validYuanbaoToken(s string) bool {
k, sec, ok := strings.Cut(strings.TrimSpace(s), ":")
return ok && k != "" && sec != ""
}
if !validYuanbaoToken(os.Args[tokenFlagIdx+1]) { /* reject before setup runs */ } Try / catch
if err := runYuanbaoSetup(...); err != nil {
if strings.Contains(err.Error(), "--token is required") {
fmt.Fprintln(os.Stderr, `usage: cc-connect setup yuanbao --token "app_key:app_secret"`)
os.Exit(2)
}
return err
} Prevention
- Include the full app_key:app_secret with a non-empty secret
- Quote the token argument in shell commands and scripts
- Verify the pasted token contains a colon before running setup
- Keep tokens in an env var or config rather than retyping them
When it happens
Trigger: Running yuanbao setup (create or any non-bind mode) without --token, or with a token that has no ':', an empty key, or an empty secret segment.
Common situations: Missing --token flag on the command line; token pasted incompletely; shell ate the ':' portion due to quoting; user confused the token format with a plain API key.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- bind mode requires --token (format: app_key:app_secret)
- bind mode requires --token
- app_id/app_secret are required
- new/QR mode does not accept --token; use `cc-connect weixin
- %s must be true or false
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/352159a3e6034753.
Report an issue: GitHub.