{"record":{"id":"255d837a521839a1","repo":"AlistGo/alist","slug":"failed-to-get-bdstoken-from-baidu-youth-cookie","errorCode":null,"errorMessage":"failed to get bdstoken from baidu youth cookie","messagePattern":"failed to get bdstoken from baidu youth cookie","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/baidu_youth/util.go","lineNumber":207,"sourceCode":"\t\t}, nil)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", \"\", err\n\t\t}\n\t\tif uk == 0 {\n\t\t\tuk = int64(utils.Json.Get(body, \"result\", \"uk\").ToInt())\n\t\t}\n\t\tif bdstoken == \"\" {\n\t\t\tbdstoken = utils.Json.Get(body, \"result\", \"bdstoken\").ToString()\n\t\t}\n\t\tif sk == \"\" {\n\t\t\tsk = utils.Json.Get(body, \"result\", \"sk\").ToString()\n\t\t}\n\t}\n\tif sk == \"\" {\n\t\tsk, _ = d.getUserSK(ctx)\n\t}\n\tif bdstoken == \"\" {\n\t\treturn 0, \"\", \"\", fmt.Errorf(\"failed to get bdstoken from baidu youth cookie\")\n\t}\n\tif uk == 0 {\n\t\treturn 0, \"\", \"\", fmt.Errorf(\"failed to get uk from baidu youth cookie\")\n\t}\n\treturn uk, bdstoken, sk, nil\n}\n\nfunc (d *BaiduYouth) getFiles(ctx context.Context, dir string) ([]File, error) {\n\tpage := 1\n\tnum := 1000\n\tparams := map[string]string{\n\t\t\"dir\": dir,\n\t}\n\tif d.OrderBy != \"\" {\n\t\tparams[\"order\"] = d.OrderBy\n\t\tif d.OrderDirection == \"desc\" {\n\t\t\tparams[\"desc\"] = \"1\"\n\t\t} else {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/baidu_youth/util.go#L189-L225","documentation":"Returned by BaiduYouth's credential bootstrap (drivers/baidu_youth/util.go:207): after scanning cookies and API responses, no bdstoken could be found. The bdstoken is required to sign state-changing requests; an empty one means the provided cookies are incomplete for this endpoint.","triggerScenarios":"Init/getUserINFO path where neither the cookie jar nor the userinfo response contained result.bdstoken: user supplied only BDUSS without SToken/bdstoken, or Baidu served an error page so the JSON extraction found nothing.","commonSituations":"Config copied with a partial cookie string; expired cookies making the userinfo call return errno!=0 body without bdstoken; Baidu renaming the JSON field.","solutions":["Refresh the cookie config: log in to pan.baidu.com in a browser and copy the full cookie set (BDUSS, SToken, bdstoken if present)","Verify the cookies are still valid by loading the site in the same browser session","Check that the userinfo request succeeded (no errno!=0) before this extraction runs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate the cookie config before first use\nfunc hasRequiredYouthCookies(raw string) bool {\n    for _, key := range []string{\"BDUSS\", \"SToken\"} {\n        if !strings.Contains(raw, key+\"=\") {\n            return false\n        }\n    }\n    return true\n}\nif !hasRequiredYouthCookies(d.Addition.Cookie) {\n    return fmt.Errorf(\"cookie config missing BDUSS/SToken; copy the full cookie set from a logged-in browser\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy the complete cookie string from a live pan.baidu.com session, not a single field","Treat 'failed to get bdstoken/uk' as a config problem: refresh cookies, do not retry requests","Re-validate cookies after any password change or device revocation on the Baidu account"],"tags":["baidu-youth","config","cookie","auth"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}