{"record":{"id":"86286693190f1320","repo":"chenhg5/cc-connect","slug":"acp-authenticate-s-w","errorCode":null,"errorMessage":"acp: authenticate (%s): %w","messagePattern":"acp: authenticate \\((.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/acp/session.go","lineNumber":202,"sourceCode":"\tvar initOut acpInitializeResult\n\tif err := json.Unmarshal(res, &initOut); err != nil {\n\t\treturn fmt.Errorf(\"acp: parse initialize result: %w\", err)\n\t}\n\tlistSupported := len(initOut.AgentCapabilities.SessionCapabilities.List) > 0\n\tslog.Debug(\"acp: initialized\",\n\t\t\"protocol\", initOut.ProtocolVersion,\n\t\t\"load_session\", initOut.AgentCapabilities.LoadSession,\n\t\t\"list_sessions\", listSupported,\n\t)\n\tif s.callbacks != nil {\n\t\ts.callbacks.reportListSupported(listSupported)\n\t}\n\n\tif strings.TrimSpace(authMethod) != \"\" {\n\t\tif _, err := s.tr.call(s.ctx, \"authenticate\", map[string]any{\n\t\t\t\"methodId\": authMethod,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"acp: authenticate (%s): %w\", authMethod, err)\n\t\t}\n\t\tslog.Debug(\"acp: authenticated\", \"method_id\", authMethod)\n\t}\n\n\twantResume := resumeSessionID != \"\" && resumeSessionID != core.ContinueSession\n\tif wantResume && initOut.AgentCapabilities.LoadSession {\n\t\tloadParams := map[string]any{\n\t\t\t\"sessionId\":  resumeSessionID,\n\t\t\t\"cwd\":        s.workDir,\n\t\t\t\"mcpServers\": []any{},\n\t\t}\n\t\tloadRes, err := s.tr.call(s.ctx, \"session/load\", loadParams)\n\t\tif err != nil {\n\t\t\tslog.Warn(\"acp: session/load failed, starting new session\", \"error\", err)\n\t\t} else {\n\t\t\tvar lr struct {\n\t\t\t\tSessionID string         `json:\"sessionId\"`\n\t\t\t\tModes     *acpModesBlock `json:\"modes\"`","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/acp/session.go#L184-L220","documentation":"Wrapped when the JSON-RPC `authenticate` call fails during handshake. Authentication is only attempted when an authMethod id is configured; the agent rejected the method id or the request errored, and the session is closed.","triggerScenarios":"authMethod is set (non-empty after TrimSpace) and the agent returns a JSON-RPC error for `authenticate` — unknown methodId, expired/invalid credentials, or transport/timeout failure during the call.","commonSituations":"Configured auth_method id does not match one advertised by the agent (agent upgrade renamed method ids); agent not logged in / OAuth token expired; authenticating against an agent that requires a different login flow.","solutions":["Run the agent's login/auth flow separately (e.g. `agent login`) so credentials are valid before cc-connect starts.","Check the authMethod id against the methods the agent advertises in its initialize result (authMethods) and update config.","Clear the authMethod from config if the agent needs no auth, since authenticate is skipped when it is empty.","Re-authenticate to refresh an expired token, then restart cc-connect."],"exampleFix":"// before\nauth_method = \"oauth-personal\"  // agent renamed this id\n// after\nauth_method = \"login-with-api-key\"  // id from agent's authMethods list","handlingStrategy":"validation","validationCode":"// verify authMethod against agent-advertised methods after initialize\nvalid := false\nfor _, m := range initOut.AuthMethods {\n    if m.ID == cfg.AuthMethod { valid = true; break }\n}\nif cfg.AuthMethod != \"\" && !valid {\n    return fmt.Errorf(\"auth method %q not offered by agent\", cfg.AuthMethod)\n}","typeGuard":null,"tryCatchPattern":"sess, err := agent.StartSession(ctx, id, nil)\nif err != nil && strings.Contains(err.Error(), \"acp: authenticate\") {\n    slog.Error(\"ACP auth failed — run agent login flow, then restart\", \"err\", err)\n    return err\n}","preventionTips":["Run the agent's interactive login before starting cc-connect so tokens are fresh.","After agent upgrades, re-check auth method ids advertised by the agent.","Omit auth_method in config when the agent needs no authentication."],"tags":["acp","authentication","handshake","json-rpc"],"backgroundTag":"authentication-required","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}