{"record":{"id":"b5abf2dd68664122","repo":"AlistGo/alist","slug":"mediafire-action-token-failed-s","errorCode":null,"errorMessage":"MediaFire action token failed: %s","messagePattern":"MediaFire action token failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/mediafire/util.go","lineNumber":529,"sourceCode":"\tif d.actionToken != \"\" {\n\t\treturn d.actionToken, nil\n\t}\n\n\tdata := map[string]string{\n\t\t\"type\":            \"upload\",\n\t\t\"lifespan\":        \"1440\",\n\t\t\"response_format\": \"json\",\n\t\t\"session_token\":   d.SessionToken,\n\t}\n\n\tvar resp MediafireActionTokenResponse\n\t_, err := d.postForm(\"/user/get_action_token.php\", data, &resp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.Response.Result != \"Success\" {\n\t\treturn \"\", fmt.Errorf(\"MediaFire action token failed: %s\", resp.Response.Result)\n\t}\n\n\treturn resp.Response.ActionToken, nil\n}\n\nfunc (d *Mediafire) pollUpload(ctx context.Context, key string) (*MediafirePollResponse, error) {\n\n\tactionToken, err := d.getActionToken(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get action token: %w\", err)\n\t}\n\n\t//fmt.Printf(\"Debug Key: %+v\\n\", key)\n\n\tquery := map[string]string{\n\t\t\"key\":             key,\n\t\t\"response_format\": \"json\",\n\t\t\"session_token\":   actionToken, /* d.SessionToken */","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L511-L547","documentation":"The dedicated action-token endpoint /user/get_action_token.php returned Result != Success. The session_token in d.SessionToken was rejected or the token type requested is not granted. Action tokens authorize mutation endpoints (upload, delete); this error blocks every upload-path operation that starts with getActionToken.","triggerScenarios":"Session token expired (MediaFire sessions have a limited lifespan and are invalidated by re-login elsewhere); session_token missing or empty because Init/login never completed; requesting an action token type the app is not entitled to; account locked or password changed.","commonSituations":"Driver instance held for a long time (daemon process) without re-login; credentials rotated outside the app; concurrent logins with the same account invalidating older sessions; misconfigured stored credentials where the session token was never persisted.","solutions":["Re-run login to obtain a fresh session token, then retry the action token request","Verify d.SessionToken is non-empty before the call and that Init succeeded","If re-login also fails, re-validate email/password (or app credentials) entirely","Persist and reuse action tokens within their requested 1440-minute lifespan to reduce token churn"],"exampleFix":"// before\nif resp.Response.Result != \"Success\" {\n    return \"\", fmt.Errorf(\"MediaFire action token failed: %s\", resp.Response.Result)\n}\n\n// after\nif resp.Response.Result != \"Success\" {\n    // session is likely stale; force re-login on next operation\n    d.SessionToken = \"\"\n    return \"\", fmt.Errorf(\"MediaFire action token failed: %s\", resp.Response.Result)\n}","handlingStrategy":"retry","validationCode":"if d.SessionToken == \"\" {\n    return errors.New(\"cannot get action token: no session; login first\")\n}","typeGuard":null,"tryCatchPattern":"// On action-token result failure, re-login once then retry\nif _, err := d.getActionToken(ctx); err != nil {\n    if strings.Contains(err.Error(), \"action token failed\") {\n        if d.relogin() == nil {\n            return d.getActionToken(ctx)\n        }\n    }\n    return err\n}","preventionTips":["Invalidate d.SessionToken when this fires so the next call re-logs in","Persist session with a timestamp and refresh before expiry","Avoid multiple logins for one account across processes"],"tags":["mediafire","auth-token","session","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}