{"record":{"id":"2039f7f26b7d816d","repo":"AlexxIT/go2rtc","slug":"loginresp-errormsg","errorCode":null,"errorMessage":"loginResp.ErrorMsg","messagePattern":"loginResp\\.ErrorMsg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tuya/tuya.go","lineNumber":161,"sourceCode":"\t\tOptions:     `{\"group\":1}`,\n\t}\n\n\tif tuya.IsEmailAddress(email) {\n\t\turl = fmt.Sprintf(\"https://%s/api/private/email/login\", serverHost)\n\t\tloginReq.Email = email\n\t} else {\n\t\turl = fmt.Sprintf(\"https://%s/api/private/phone/login\", serverHost)\n\t\tloginReq.Mobile = email\n\t}\n\n\tloginResp, err = performLogin(client, url, loginReq, serverHost)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !loginResp.Success {\n\t\treturn nil, errors.New(loginResp.ErrorMsg)\n\t}\n\n\treturn &loginResp.Result, nil\n}\n\nfunc getLoginToken(client *http.Client, serverHost, username, countryCode string) (*tuya.LoginTokenResponse, error) {\n\turl := fmt.Sprintf(\"https://%s/api/login/token\", serverHost)\n\n\ttokenReq := tuya.LoginTokenRequest{\n\t\tCountryCode: countryCode,\n\t\tUsername:    username,\n\t\tIsUid:       false,\n\t}\n\n\tjsonData, err := json.Marshal(tokenReq)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/tuya/tuya.go#L143-L179","documentation":"The Tuya cloud login (PasswordLoginResponse) returned Success=false; go2rtc surfaces the vendor's ErrorMsg string verbatim as the error. The message content comes from the Tuya OpenAPI, not go2rtc itself.","triggerScenarios":"Calling tuya login (via the apiTuya endpoint) with wrong username/password, an account locked or needing verification, or against a server/region endpoint that rejects the credentials.","commonSituations":"Tuya smart-home credentials changed or revoked; using the wrong data-center endpoint for the account; account requires 2FA/captcha; expired app account.","solutions":["Verify Tuya username and password are correct by logging into the Smart Life / Tuya app","Check the configured server host/region matches the account's data center (e.g. openapi.tuyaXX.com)","Update stored credentials after any password change","Inspect the ErrorMsg text for account-state issues (locked, verification required) and resolve in the Tuya app"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"login, err := tuya.Login(client, cfg)\nif err != nil {\n\tlog.Printf(\"tuya login failed: %v\", err) // body is vendor ErrorMsg\n\t// check credentials/region before retrying\n}","preventionTips":["Store Tuya credentials in config/env, not hardcoded, and update after password changes","Verify region/server host matches the account's data center","Periodically test login with a lightweight request to catch credential drift early"],"tags":["go","tuya","authentication"],"backgroundTag":"authentication-required","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}