diff --git a/src/oauth/google-antigravity.ts b/src/oauth/google-antigravity.ts index be81b55de58..892af97a0ba 100644 --- a/src/oauth/google-antigravity.ts +++ b/src/oauth/google-antigravity.ts @@ -38,6 +38,9 @@ const REFRESH_SKEW_MS = 5 * 60 * 1000; const REQUEST_TIMEOUT_MS = 30_000; const ONBOARD_ATTEMPTS = 5; const ONBOARD_POLL_MS = 2_000; +// A person without a local browser copies the redirect URL from the address bar and pastes it back by +// hand, which takes far longer than the callback base class's default wait. +const ANTIGRAVITY_LOGIN_TIMEOUT_MS = 20 * 60 * 1000; function requestSignal(signal: AbortSignal | undefined): AbortSignal { const timeout = AbortSignal.timeout(REQUEST_TIMEOUT_MS); @@ -159,7 +162,7 @@ function credentialsFromPayload(payload: GoogleTokenPayload, refreshFallback = " }; } -class AntigravityOAuthFlow extends OAuthCallbackFlow { +export class AntigravityOAuthFlow extends OAuthCallbackFlow { #verifier = ""; #forceAccountSelect: boolean; @@ -170,6 +173,7 @@ class AntigravityOAuthFlow extends OAuthCallbackFlow { callbackHostname: "127.0.0.1", callbackBindHostname: "127.0.0.1", redirectUri: `http://127.0.0.1:${CALLBACK_PORT}${CALLBACK_PATH}`, + timeoutMs: ANTIGRAVITY_LOGIN_TIMEOUT_MS, } satisfies OAuthCallbackFlowOptions); this.#forceAccountSelect = opts?.forceAccountSelect === true; } diff --git a/tests/oauth/oauth-callback-server.test.ts b/tests/oauth/oauth-callback-server.test.ts index feeb4301895..8bb23fa1b6f 100644 --- a/tests/oauth/oauth-callback-server.test.ts +++ b/tests/oauth/oauth-callback-server.test.ts @@ -1,4 +1,5 @@ import { describe, expect, test } from "bun:test"; +import { AntigravityOAuthFlow } from "../../src/oauth/google-antigravity"; import { OAuthCallbackFlow, type OAuthCallbackFlowOptions } from "../../src/oauth/callback-server"; import type { OAuthController, OAuthCredentials } from "../../src/oauth/types"; @@ -89,6 +90,12 @@ describe("OAuth callback server defaults", () => { } }); + test("Google Antigravity sign-in waits 20 minutes for the pasted redirect URL, not the 5-minute default", () => { + // A person without a local browser copies the redirect URL from the address bar and pastes it back by hand. + const flow = new AntigravityOAuthFlow({ onAuth: () => {} } as unknown as OAuthController); + expect(flow.timeoutMs).toBe(20 * 60 * 1000); + }); + test("manual-input loop rejects a code#state paste with a foreign suffix and re-prompts", async () => { let prompts = 0; const flow = new ManualFallbackFlow(