{"record":{"id":"84ffdd5119997808","repo":"xtekky/gpt4free","slug":"failed-to-get-access-token-e-refresh-your-cook","errorCode":null,"errorMessage":"Failed to get access token: {e}, refresh your cookies / log in into {cls.domain}","messagePattern":"Failed to get access token: (.+?), refresh your cookies / log in into (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Reka.py","lineNumber":169,"sourceCode":"            \"sec-ch-ua-platform\": '\"macOS\"',\n            \"sec-fetch-dest\": \"empty\",\n            \"sec-fetch-mode\": \"cors\",\n            \"sec-fetch-site\": \"same-origin\",\n            \"user-agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36\",\n        }\n\n        try:\n            response = requests.get(\n                f\"{cls.url}/bff/auth/access_token\",\n                cookies=cls.cookies,\n                headers=headers,\n                proxies=cls.proxy,\n            )\n\n            return response.json()[\"accessToken\"]\n\n        except Exception as e:\n            raise ValueError(\n                f\"Failed to get access token: {e}, refresh your cookies / log in into {cls.domain}\"\n            )\n","sourceCodeStart":151,"sourceCodeEnd":172,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Reka.py#L151-L172","documentation":"Raised as ValueError by Reka.get_access_token when the request to {url}/bff/auth/access_token fails or its JSON lacks 'accessToken'. Any exception (network error, non-200, JSON decode error, missing key) is wrapped in this message telling you to refresh cookies or log in again.","triggerScenarios":"Reka auth endpoint rejects the appSession cookie (expired/revoked), the request fails through the proxy, or the response body is not the expected JSON — the except Exception catches all of it.","commonSituations":"appSession cookie expired since login, Reka changed its BFF auth route, proxy blocking the auth request, rate-limited token endpoint.","solutions":["Log in to Reka again in the browser to refresh appSession, then retry","Pass api_key directly so no token exchange is needed","Check the proxy setting (cls.proxy) if the auth request itself is failing"],"exampleFix":"# before\nresponse = client.chat.completions.create(model='reka-core', messages=msgs)  # Failed to get access token\n\n# after\nresponse = client.chat.completions.create(model='reka-core', messages=msgs, api_key=os.environ['REKA_API_KEY'])","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = ...create(...)\nexcept ValueError as e:\n    if 'Failed to get access token' in str(e):\n        result = ...create(..., api_key=os.environ['REKA_API_KEY'])\n    else:\n        raise","preventionTips":["Treat token-exchange failures as a signal the session is stale: prefer a stored api_key for unattended jobs","Verify proxy connectivity if auth requests fail in proxied environments"],"tags":["authentication","token-refresh","reka","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}