{"record":{"id":"9b777ac098f4b2ea","repo":"multica-ai/multica","slug":"timed-out-waiting-for-authentication","errorCode":null,"errorMessage":"timed out waiting for authentication","messagePattern":"timed out waiting for authentication","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_auth.go","lineNumber":310,"sourceCode":"\t\t}\n\t}()\n\tdefer srv.Close()\n\n\t// Open the browser.\n\tfmt.Fprintln(os.Stderr, \"Opening browser to authenticate...\")\n\tif err := openBrowser(loginURL); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Could not open browser automatically.\\n\")\n\t}\n\tfmt.Fprint(os.Stderr, browserLoginInstructions(loginURL, callbackHost, port, runningInSSHSession()))\n\n\t// Wait for the JWT from the callback (timeout 5 minutes).\n\tvar jwtToken string\n\tselect {\n\tcase jwtToken = <-jwtCh:\n\tcase err := <-errCh:\n\t\treturn fmt.Errorf(\"local server error: %w\", err)\n\tcase <-time.After(5 * time.Minute):\n\t\treturn fmt.Errorf(\"timed out waiting for authentication\")\n\t}\n\n\t// Use the JWT to create a PAT via the existing API.\n\tclient := cli.NewAPIClient(serverURL, \"\", jwtToken)\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\thostname, _ := os.Hostname()\n\tif hostname == \"\" {\n\t\thostname = \"unknown\"\n\t}\n\tpatName := fmt.Sprintf(\"CLI (%s)\", hostname)\n\texpiresInDays := 90\n\n\tvar patResp struct {\n\t\tToken string `json:\"token\"`\n\t}","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_auth.go#L292-L328","documentation":"Browser login waits on a select with a 5-minute time.After for the JWT to arrive via the local callback. If nothing completes the flow in that window (user never signed in, browser never opened, callback never reached the listener), the command times out.","triggerScenarios":"User stepped away; browser failed to open (headless/SSH) and the printed URL was not used; sign-in page opened but never finished; callback blocked from reaching localhost (browser in a remote desktop/VM while CLI runs elsewhere).","commonSituations":"SSH/remote sessions where the browser opens on another machine than the listener; slow SSO flows exceeding 5 minutes; forgotten terminal after kicking off login.","solutions":["Rerun login and complete the browser sign-in promptly; copy the printed URL manually if the browser did not open","Ensure the browser and the CLI run on the same host (or that the callback host is reachable from the browser)","For SSH sessions, use the printed remote-friendly instructions or switch to token login","Use `multica login --token <PAT>` to bypass the browser flow entirely"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# headless/SSH detection: choose token login up front\n[ -n \"$SSH_CONNECTION\" ] && [ -z \"$DISPLAY\" ] && use_token_login=1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In automation always use --token login, never the browser flow","Complete browser sign-in within the 5-minute window or rerun"],"tags":["cli","auth","login","timeout","browser"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}