AlistGo/alist · error
failed to get bdstoken from baidu youth cookie
Error message
failed to get bdstoken from baidu youth cookie
What it means
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.
Source
Thrown at drivers/baidu_youth/util.go:207
}, nil)
if err != nil {
return 0, "", "", err
}
if uk == 0 {
uk = int64(utils.Json.Get(body, "result", "uk").ToInt())
}
if bdstoken == "" {
bdstoken = utils.Json.Get(body, "result", "bdstoken").ToString()
}
if sk == "" {
sk = utils.Json.Get(body, "result", "sk").ToString()
}
}
if sk == "" {
sk, _ = d.getUserSK(ctx)
}
if bdstoken == "" {
return 0, "", "", fmt.Errorf("failed to get bdstoken from baidu youth cookie")
}
if uk == 0 {
return 0, "", "", fmt.Errorf("failed to get uk from baidu youth cookie")
}
return uk, bdstoken, sk, nil
}
func (d *BaiduYouth) getFiles(ctx context.Context, dir string) ([]File, error) {
page := 1
num := 1000
params := map[string]string{
"dir": dir,
}
if d.OrderBy != "" {
params["order"] = d.OrderBy
if d.OrderDirection == "desc" {
params["desc"] = "1"
} else {View on GitHub (pinned to 843d9dc814)
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
Defensive patterns
Strategy: validation
Validate before calling
// validate the cookie config before first use
func hasRequiredYouthCookies(raw string) bool {
for _, key := range []string{"BDUSS", "SToken"} {
if !strings.Contains(raw, key+"=") {
return false
}
}
return true
}
if !hasRequiredYouthCookies(d.Addition.Cookie) {
return fmt.Errorf("cookie config missing BDUSS/SToken; copy the full cookie set from a logged-in browser")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Config copied with a partial cookie string; expired cookies making the userinfo call return errno!=0 body without bdstoken; Baidu renaming the JSON field.
Related errors
- failed to get uk from baidu youth cookie
- cookie is empty
- baidu youth sk is empty
- clientID and clientSecret are required in client_credentials
- api_key is empty
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/255d837a521839a1.
Report an issue: GitHub.