xtekky/gpt4free · error · RuntimeError
OAuth error: {OAuthCallbackHandler.callback_error}
Error message
OAuth error: {OAuthCallbackHandler.callback_error} What it means
RuntimeError raised by Antigravity's local OAuth callback flow: after the loopback HTTP server thread finishes (callback received, timeout, or stop flag), OAuthCallbackHandler.callback_error is non-empty — the OAuth redirect arrived carrying an error (e.g. error=access_denied in the query string) instead of an authorization code. The message surfaces exactly what the callback handler recorded.
Source
Thrown at g4f/Provider/needs_auth/Antigravity.py:312
"""Wait for OAuth callback and return result."""
# Poll for result instead of blocking on thread join
start_time = time.time()
while time.time() - start_time < self.timeout:
if (
OAuthCallbackHandler.callback_result
or OAuthCallbackHandler.callback_error
):
break
time.sleep(0.1)
# Signal thread to stop
self._stop_flag = True
if self._thread:
self._thread.join(timeout=2.0)
if OAuthCallbackHandler.callback_error:
raise RuntimeError(f"OAuth error: {OAuthCallbackHandler.callback_error}")
return OAuthCallbackHandler.callback_result
def stop(self):
"""Stop the callback server."""
self._stop_flag = True
if self.server:
try:
self.server.server_close()
except Exception:
pass
self.server = None
# Antigravity base URLs with fallback order
# For streaming/generation: prefer production (most stable)
# For discovery: sandbox daily may work faster
BASE_URLS = [View on GitHub (pinned to 973504e177)
Solutions
- Read callback_error in the message — e.g. 'access_denied' means the consent was refused; retry and approve it.
- Ensure the loopback callback port is reachable and not occupied by another process, so the real redirect (not an error) is captured.
- Re-run the login flow from scratch to regenerate fresh state/nonce; stale half-completed flows commonly error out.
- If the error mentions redirect_uri or client registration, the provider's OAuth client config changed — update g4f or use the service-account credential path (ANTIGRAVITY_SERVICE_ACCOUNT) instead.
Defensive patterns
Strategy: try-catch
Try / catch
try:
result = handler.wait_for_callback()
except RuntimeError as e:
if 'OAuth error' in str(e):
if 'access_denied' in str(e):
raise PermissionError('User denied Antigravity consent') from e
raise # config/registration errors need manual attention Prevention
- Complete the consent screen without cancelling.
- Ensure the loopback callback port is free before starting the flow.
- Surface callback_error verbatim in logs — OAuth error codes pinpoint the cause.
When it happens
Trigger: Running the Antigravity OAuth login (local callback server + browser consent) and the provider redirecting back with an error query param: user denied consent, Google/Antigravity returned invalid_grant or access_denied, the client_id/redirect_uri misregistration produced an auth error, or the auth endpoint itself reported an error.
Common situations: Users cancelling the consent screen; OAuth client configuration changes upstream (redirect URI no longer registered); sandboxed/headless environments where the browser step is intercepted; clock skew breaking state validation.
Related errors
- OAuth callback timed out
- No authorization code received
- Failed to read OAuth credentials from {path}: {e}
- ANTIGRAVITY_SERVICE_ACCOUNT environment variable not set. Pl
- No refresh token found in credentials.
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/9ea67467901c9d66.
Report an issue: GitHub.