{"record":{"id":"54a35f9b3ffb6d25","repo":"netbirdio/netbird","slug":"waiting-sso-login-failed-with-v","errorCode":null,"errorMessage":"waiting sso login failed with: %v","messagePattern":"waiting sso login failed with: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":357,"sourceCode":"\tif err := server.RestoreResidualState(ctx, profilemanager.NewServiceManager(configFilePath).GetStatePath()); err != nil {\n\t\tlog.Warnf(\"failed to restore residual state: %v\", err)\n\t}\n\tnbnet.Init()\n\n\terr = foregroundLogin(ctx, cmd, config, setupKey, activeProf.ID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"foreground login failed: %v\", err)\n\t}\n\tcmd.Println(\"Logging successfully\")\n\treturn nil\n}\n\nfunc handleSSOLogin(ctx context.Context, cmd *cobra.Command, loginResp *proto.LoginResponse, client proto.DaemonServiceClient, pm *profilemanager.ProfileManager) error {\n\topenURL(cmd, loginResp.VerificationURIComplete, loginResp.UserCode, noBrowser, showQR)\n\n\tresp, err := client.WaitSSOLogin(ctx, &proto.WaitSSOLoginRequest{UserCode: loginResp.UserCode, Hostname: hostName})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"waiting sso login failed with: %v\", err)\n\t}\n\n\tif resp.Email != \"\" {\n\t\terr = pm.SetActiveProfileState(&profilemanager.ProfileState{\n\t\t\tEmail: resp.Email,\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"failed to set active profile email: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc foregroundLogin(ctx context.Context, cmd *cobra.Command, config *profilemanager.Config, setupKey string, profileID profilemanager.ID) error {\n\tauthClient, err := auth.NewAuth(ctx, config.PrivateKey, config.ManagementURL, config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create auth client: %v\", err)","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L339-L375","documentation":"handleSSOLogin's WaitSSOLogin long-poll RPC to the daemon failed. The daemon blocks waiting for the IdP callback after the user opens the verification URI; this error appears when the CLI's context is cancelled (Ctrl+C), the daemon-side wait times out or expires, the daemon loses its connection to management mid-wait, or the gRPC transport drops.","triggerScenarios":"User aborts the command before completing browser auth; device/user code expires before approval; daemon restarted or crashed during the wait; management connection lost; ctx deadline exceeded on the CLI side.","commonSituations":"Browser auth left unfinished in a remote SSH session; IdP slow or down (SAML/OIDC latency) so the code expires; Daemon crash-looping or being upgraded mid-login","solutions":["Rerun 'netbird login' and complete the browser step promptly (mind the code expiry window)","Ensure the daemon stays up during the flow (netbird service status) and check its logs","Verify daemon-to-management connectivity and IdP health","If aborting intentionally, Ctrl+C early rather than letting the code expire confusingly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the daemon connection is alive before entering the long wait\nif _, err := client.Status(ctx, &proto.StatusRequest{}); err != nil {\n    return fmt.Errorf(\"daemon unavailable before SSO wait: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.WaitSSOLogin(ctx, &proto.WaitSSOLoginRequest{...})\nif err != nil {\n    if ctx.Err() != nil {\n        return fmt.Errorf(\"sso wait canceled: %w\", err)\n    }\n    return fmt.Errorf(\"waiting sso login failed with: %w\", err)\n}","preventionTips":["Complete the browser step immediately after the code renders","Use a CLI-side context with a timeout longer than the code lifetime so expiry is reported as deadline, not hang","Script wrappers should check daemon liveness first to distinguish transport drops from auth failures"],"tags":["grpc","sso","login","daemon","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}