{"record":{"id":"0702d22c5968102b","repo":"AlistGo/alist","slug":"getsessiontoken-failed-to-get-session-token-st","errorCode":null,"errorMessage":"getSessionToken :: failed to get session token, status code: %d","messagePattern":"getSessionToken :: failed to get session token, status code: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/mediafire/util.go","lineNumber":105,"sourceCode":"\t\tcookieMap := make(map[string]string)\n\t\tfor _, cookie := range resp.Cookies() {\n\t\t\tcookieMap[cookie.Name] = cookie.Value\n\t\t}\n\n\t\tif len(cookieMap) > 0 {\n\n\t\t\tvar cookies []string\n\t\t\tfor name, value := range cookieMap {\n\t\t\t\tcookies = append(cookies, fmt.Sprintf(\"%s=%s\", name, value))\n\t\t\t}\n\t\t\td.Cookie = strings.Join(cookies, \"; \")\n\t\t\top.MustSaveDriverStorage(d)\n\n\t\t\t//fmt.Printf(\"getSessionToken :: Captured cookies: %s\\n\", d.Cookie)\n\t\t}\n\n\t} else {\n\t\treturn \"\", fmt.Errorf(\"getSessionToken :: failed to get session token, status code: %d\", resp.StatusCode)\n\t}\n\n\td.SessionToken = tokenResp.Response.SessionToken\n\n\t//fmt.Printf(\"Init :: Obtain Session Token %v\", d.SessionToken)\n\n\top.MustSaveDriverStorage(d)\n\n\treturn d.SessionToken, nil\n}\n\nfunc (d *Mediafire) renewToken(_ context.Context) error {\n\tquery := map[string]string{\n\t\t\"session_token\":   d.SessionToken,\n\t\t\"response_format\": \"json\",\n\t}\n\n\tvar resp MediafireRenewTokenResponse","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L87-L123","documentation":"getSessionToken got a non-200 HTTP status from MediaFire's get_session_token endpoint. Unlike the empty-token case (875), here the request failed at the HTTP layer: 403 from Cloudflare/bot protection when headers (secChUa, userAgent, Referer) don't match a real browser, 429 rate limiting, 5xx outages, or captive-portal responses from restricted networks.","triggerScenarios":"Calling Init with a cookie rejected outright (403); rapid restarts hammering the endpoint (429); missing or default User-Agent / Sec-Ch-Ua fields (d.userAgent, d.secChUa empty in Addition); proxy or firewall intercepting mediafire.com.","commonSituations":"Instances restarted in a loop re-initializing storage; Datacenter IPs that Cloudflare flags; default config where browser-fingerprint headers were never filled in.","solutions":["Retry with backoff — 429/5xx are transient","Verify d.Addition userAgent/secChUa/secChUaPlatform match a real browser profile (these are sent verbatim)","Check the instance's egress IP isn't Cloudflare-blocked (test curl -A '<ua>' https://www.mediafire.com from the host)","Re-extract the cookie: an invalid cookie can also produce 403 rather than 200-with-error"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Classify by status: 429/5xx -> retry with exponential backoff (respect Retry-After); 403 -> do not retry, log that the cookie/fingerprint (userAgent, secChUa headers) must be refreshed; other codes -> surface status code with the error.","preventionTips":["Fill userAgent, secChUa, secChUaPlatform in Addition to match a real browser","Avoid rapid re-Init loops that hammer the token endpoint","Run from residential or unblocked egress IPs; test with curl before blaming the code"],"tags":["mediafire","http-status","rate-limit","cloudflare","authentication"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}