{"record":{"id":"0bbd774c809689e4","repo":"xtekky/gpt4free","slug":"oauth-callback-timed-out","errorCode":null,"errorMessage":"OAuth callback timed out","messagePattern":"OAuth callback timed out","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Antigravity.py","lineNumber":856,"sourceCode":"                print(\"Please open the URL above manually.\\n\")\n        else:\n            if not server_started:\n                print(\n                    f\"\\nCould not start local callback server on port {OAUTH_CALLBACK_PORT}.\"\n                )\n                print(\"You may need to close any application using that port.\\n\")\n\n            print(f\"\\nPlease open this URL in your browser:\\n\")\n            print(f\"{auth_url}\\n\")\n\n        if server_started:\n            print(\"Waiting for authentication callback...\")\n\n            try:\n                callback_result = callback_server.wait_for_callback()\n\n                if not callback_result:\n                    raise RuntimeError(\"OAuth callback timed out\")\n\n                code = callback_result.get(\"code\")\n                callback_state = callback_result.get(\"state\")\n\n                if not code:\n                    raise RuntimeError(\"No authorization code received\")\n\n                print(\"\\n✓ Authorization code received. Exchanging for tokens...\")\n\n                # Exchange code for tokens\n                tokens = await cls.exchange_code_for_tokens(\n                    code, callback_state or state\n                )\n\n                print(f\"✓ Authentication successful!\")\n                if tokens.get(\"email\"):\n                    print(f\"  Logged in as: {tokens['email']}\")\n                if tokens.get(\"project_id\"):","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Antigravity.py#L838-L874","documentation":"In the local-callback login flow, the provider starts a localhost HTTP server and blocks in wait_for_callback(); this error fires when that call returns a falsy result — no callback request ever arrived and the wait mechanism gave up. The browser never hit the redirect URI on the local port.","triggerScenarios":"wait_for_callback() returns None/empty because the OS browser could not reach http://localhost:<port>/callback: port occupied by another process, browser opened on a different machine (SSH/remote session), firewall blocking loopback listeners, or user never completed consent.","commonSituations":"Running the login flow inside a container/remote server where the printed URL must be opened and port-forwarded manually; port already bound by a previous crashed attempt; headless environments without a browser.","solutions":["Free the local port (kill the process holding it) or let the provider pick another, then restart login.","On remote/headless machines, set up an SSH tunnel for the callback port and open the URL in your local browser, or use the manual paste flow instead.","Open the printed authorization URL in a browser on the same machine and complete consent."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import socket\n\ndef callback_port_free(port: int) -> bool:\n    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:\n        return s.connect_ex((\"127.0.0.1\", port)) != 0","typeGuard":null,"tryCatchPattern":"try:\n    tokens = await Antigravity.login()\nexcept RuntimeError as e:\n    if \"OAuth callback timed out\" in str(e):\n        # free the port / fix port-forwarding, then restart login\n        raise","preventionTips":["Ensure the callback port is free before starting login (kill stale servers)","On remote machines, SSH-forward the callback port or use the manual paste flow","Open the auth URL promptly and complete consent so the callback actually fires"],"tags":["oauth","callback","localhost","antigravity","login"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}