{"record":{"id":"c0230c4704626121","repo":"netbirdio/netbird","slug":"waiting-for-browser-login-failed-v-c0230c","errorCode":null,"errorMessage":"waiting for browser login failed: %v","messagePattern":"waiting for browser login failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":425,"sourceCode":"\t} else if profileState.Email != \"\" {\n\t\thint = profileState.Email\n\t}\n\n\toAuthFlow, err := auth.NewOAuthFlow(ctx, config, util.HasGraphicalSession(), false, hint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tflowInfo, err := oAuthFlow.RequestAuthInfo(context.TODO())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting a request OAuth flow info failed: %v\", err)\n\t}\n\n\topenURL(cmd, flowInfo.VerificationURIComplete, flowInfo.UserCode, noBrowser, showQR)\n\n\ttokenInfo, err := oAuthFlow.WaitToken(context.TODO(), flowInfo)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"waiting for browser login failed: %v\", err)\n\t}\n\n\treturn &tokenInfo, nil\n}\n\nfunc openURL(cmd *cobra.Command, verificationURIComplete, userCode string, noBrowser, showQR bool) {\n\tvar codeMsg string\n\tif userCode != \"\" && !strings.Contains(verificationURIComplete, userCode) {\n\t\tcodeMsg = fmt.Sprintf(\"and enter the code %s to authenticate.\", userCode)\n\t}\n\n\tif noBrowser {\n\t\tcmd.Println(\"Use this URL to log in:\\n\\n\" + verificationURIComplete + \" \" + codeMsg)\n\t} else {\n\t\tcmd.Println(\"Please do the SSO login in your browser. \\n\" +\n\t\t\t\"If your browser didn't open automatically, use this URL to log in:\\n\\n\" +\n\t\t\tverificationURIComplete + \" \" + codeMsg)\n\t}","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L407-L443","documentation":"oAuthFlow.WaitToken failed while polling for the browser login to complete. This wraps the terminal outcomes of the RFC 8628 token poll: the device/user code expired before approval, authorization was denied/pending past the deadline, a 'slow_down' exhaustion, a transport error to the token endpoint, or context cancellation. Note the source uses context.TODO(), so daemon/management-side deadlines and code expiry dominate rather than CLI-side cancellation.","triggerScenarios":"User opens the verification URI but never finishes consent before the code expires; user denies consent; network drop to management mid-poll; management restart during the poll; token endpoint returning errors repeatedly.","commonSituations":"Browser tab left open on the code page without completing login; IdP MFA prompts delayed or failing; Unstable Wi-Fi/VPN dropping the polling connection; Management redeployed mid-login","solutions":["Rerun the login and complete the browser flow immediately after the code is displayed","Keep client connectivity stable for the duration of the poll (seconds to a couple of minutes)","If it persists, check management logs for token-endpoint errors and IdP health","For automation or headless hosts, prefer setup-key login instead of the browser device flow"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Bound the wait with a real context sized to the code lifetime instead of TODO\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\ntokenInfo, err := oAuthFlow.WaitToken(ctx, flowInfo)","typeGuard":null,"tryCatchPattern":"tokenInfo, err := oAuthFlow.WaitToken(ctx, flowInfo)\nif err != nil {\n    if ctx.Err() != nil {\n        return fmt.Errorf(\"browser login timed out/canceled: %w\", err)\n    }\n    return fmt.Errorf(\"waiting for browser login failed: %w\", err)\n}","preventionTips":["Finish browser consent immediately; the user code expiry window is short","Pass a context with timeout (not context.TODO) when calling WaitToken from code","Prefer setup-key registration for automated or slow-to-approve environments"],"tags":["sso","oauth","device-flow","timeout","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}