{"record":{"id":"338e842f141b63c5","repo":"AlistGo/alist","slug":"wukong-get-upload-auth-token-failed-code-d-messa","errorCode":null,"errorMessage":"wukong get upload auth token failed: code=%d message=%s","messagePattern":"wukong get upload auth token failed: code=(.+?) message=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/wukong/driver.go","lineNumber":410,"sourceCode":"\nfunc (d *Wukong) getUploadAuthToken(ctx context.Context, uploadType string) (*uploadAuthTokenResp, error) {\n\tvar resp uploadAuthTokenResp\n\t_, err := d.client.R().\n\t\tSetContext(ctx).\n\t\tSetQueryParams(map[string]string{\n\t\t\t\"upload_source\":   uploadSourceByType(uploadType),\n\t\t\t\"type\":            uploadType,\n\t\t\t\"aid\":             d.Aid,\n\t\t\t\"device_platform\": \"web\",\n\t\t\t\"language\":        d.Language,\n\t\t}).\n\t\tSetResult(&resp).\n\t\tGet(\"/toutiao/upload/auth_token/v1/\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.Code != 0 {\n\t\treturn nil, fmt.Errorf(\"wukong get upload auth token failed: code=%d message=%s\", resp.Code, resp.Message)\n\t}\n\treturn &resp, nil\n}\n\nfunc (d *Wukong) getUploadCandidates(ctx context.Context, auth *uploadAuthTokenResp) (*getUploadCandidatesResp, error) {\n\tq := map[string]string{\n\t\t\"Action\":    \"GetUploadCandidates\",\n\t\t\"Version\":   \"2020-11-19\",\n\t\t\"SpaceName\": videoSpaceName,\n\t}\n\tvar resp getUploadCandidatesResp\n\tif err := d.vodRequest(ctx, http.MethodGet, q, nil, auth, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.ResponseMetadata.Error.Code != \"\" {\n\t\treturn nil, fmt.Errorf(\"wukong get upload candidates failed: %s\", resp.ResponseMetadata.Error.Message)\n\t}\n\treturn &resp, nil","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/wukong/driver.go#L392-L428","documentation":"Thrown by the Wukong driver's getUploadAuthToken before any upload: GET /toutiao/upload/auth_token/v1/ returned a non-zero business code. This endpoint mints the VOD (bytedanceapi.com) security token required for all subsequent vodRequest-signed calls, so its failure aborts the entire Put flow.","triggerScenarios":"Expired or invalid Wukong login state (cookies/Safari token) so auth_token is refused; the tied upload service (Toutiao/VOD) not enabled for the account; missing or wrong aid/device_platform query params; upstream rate limiting on token minting.","commonSituations":"Long-running upload started after the login session timed out; account region/language settings changed breaking the aid param; Wukong (wkbrowser pan) backend API change; too many concurrent uploads each minting tokens.","solutions":["Re-login to Wukong and save fresh driver storage, then retry the upload","Verify d.Aid and d.Language are set (non-empty, expected values) in driver config before upload","Retry with backoff once in case of transient upstream rate limiting","Check whether the Wukong pan still exposes the Toutiao upload path (API change) and update the driver if not"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if d.Aid == \"\" || d.Language == \"\" {\n    return errors.New(\"wukong driver config incomplete: aid/language missing\")\n}","typeGuard":null,"tryCatchPattern":"auth, err := d.getUploadAuthToken(ctx, uploadType)\nif err != nil {\n    if isWukongAuthErr(err) { // re-login then one retry\n        if lerr := d.relogin(ctx); lerr == nil {\n            auth, err = d.getUploadAuthToken(ctx, uploadType)\n        }\n    }\n    if err != nil {\n        return fmt.Errorf(\"upload aborted, token unavailable: %w\", err)\n    }\n}","preventionTips":["Mint the auth token immediately before use rather than caching it across uploads","Keep Wukong credentials fresh; detect auth errors early with a cheap probe before starting big uploads","Serialize token minting to avoid rate limits when uploading in parallel"],"tags":["wukong","upload","auth-token","vod","cloud-storage","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}