From 8daa953ef664a7b25f3ab3f171b7c72436f9ea61 Mon Sep 17 00:00:00 2001 From: Z User Date: Sun, 17 May 2026 22:25:33 +0000 Subject: [PATCH] fix(oauth): align antigravity OAuth metadata with official client headers Fixes #1226 The Antigravity OAuth flow sent inconsistent client metadata between the token acquisition phase and the API usage phase. String enum values (IDE_UNSPECIFIED, PLATFORM_UNSPECIFIED) were used during OAuth token exchange + loadCodeAssist + onboardUser, while numeric enums (ideType: 9, platform: , pluginType: 2) were used in runtime API calls. Google detected this fingerprint mismatch and blocked 9router accounts. Replace all string enum occurrences with the correct numeric values: - src/lib/oauth/constants/oauth.js: loadCodeAssistClientMetadata now uses getOAuthPlatformEnum() for platform and numeric 9/2 for ideType/pluginType, matching getOAuthClientMetadata() - src/lib/oauth/services/antigravity.js: getMetadata() now delegates to getOAuthClientMetadata() instead of returning hardcoded strings - src/lib/oauth/providers.js: postExchange metadata now uses getOAuthClientMetadata() instead of inline string enums - open-sse/services/usage.js: getGeminiSubscriptionInfo body now uses CLIENT_METADATA (already imported from appConstants.js) instead of inline string enums --- open-sse/services/usage.js | 6 +----- src/lib/oauth/constants/oauth.js | 4 ++-- src/lib/oauth/providers.js | 5 +++-- src/lib/oauth/services/antigravity.js | 10 +++------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/open-sse/services/usage.js b/open-sse/services/usage.js index a5e3236..8dd583e 100644 --- a/open-sse/services/usage.js +++ b/open-sse/services/usage.js @@ -305,11 +305,7 @@ async function getGeminiSubscriptionInfo(accessToken, proxyOptions = null) { "Content-Type": "application/json", }, body: JSON.stringify({ - metadata: { - ideType: "IDE_UNSPECIFIED", - platform: "PLATFORM_UNSPECIFIED", - pluginType: "GEMINI", - }, + metadata: CLIENT_METADATA, }), signal: controller.signal, }, diff --git a/src/lib/oauth/constants/oauth.js b/src/lib/oauth/constants/oauth.js index 0901064..ece8cff 100644 --- a/src/lib/oauth/constants/oauth.js +++ b/src/lib/oauth/constants/oauth.js @@ -108,8 +108,8 @@ export const ANTIGRAVITY_CONFIG = { onboardUserEndpoint: "https://cloudcode-pa.googleapis.com/v1internal:onboardUser", loadCodeAssistUserAgent: "google-api-nodejs-client/9.15.1", loadCodeAssistApiClient: "google-cloud-sdk vscode_cloudshelleditor/0.1", - // String enum matches CLIProxyAPI Go source (internal/auth/antigravity/constants.go) - loadCodeAssistClientMetadata: JSON.stringify({ ideType: "IDE_UNSPECIFIED", platform: "PLATFORM_UNSPECIFIED", pluginType: "GEMINI" }), + // Numeric enums matching Antigravity binary ClientMetadata (see getOAuthClientMetadata below) + loadCodeAssistClientMetadata: JSON.stringify({ ideType: 9, platform: getOAuthPlatformEnum(), pluginType: 2 }), }; /** diff --git a/src/lib/oauth/providers.js b/src/lib/oauth/providers.js index 46154ec..88adc4f 100644 --- a/src/lib/oauth/providers.js +++ b/src/lib/oauth/providers.js @@ -23,6 +23,7 @@ import { CLINE_CONFIG, GITLAB_CONFIG, CODEBUDDY_CONFIG, + getOAuthClientMetadata, } from "./constants/oauth"; const BASE64_BLOCK_SIZE = 4; @@ -306,7 +307,7 @@ const PROVIDERS = { return await response.json(); }, postExchange: async (tokens) => { - // Matches CLIProxyAPI Go source: string enum, no mode field + // Numeric enums matching Antigravity binary ClientMetadata const loadHeaders = { "Authorization": `Bearer ${tokens.access_token}`, "Content-Type": "application/json", @@ -315,7 +316,7 @@ const PROVIDERS = { "Client-Metadata": ANTIGRAVITY_CONFIG.loadCodeAssistClientMetadata, "x-request-source": "local", }; - const metadata = { ideType: "IDE_UNSPECIFIED", platform: "PLATFORM_UNSPECIFIED", pluginType: "GEMINI" }; + const metadata = getOAuthClientMetadata(); // Fetch user info const userInfoRes = await fetch(`${ANTIGRAVITY_CONFIG.userInfoUrl}?alt=json`, { diff --git a/src/lib/oauth/services/antigravity.js b/src/lib/oauth/services/antigravity.js index 366753b..cda6bde 100644 --- a/src/lib/oauth/services/antigravity.js +++ b/src/lib/oauth/services/antigravity.js @@ -1,6 +1,6 @@ import crypto from "crypto"; import open from "open"; -import { ANTIGRAVITY_CONFIG } from "../constants/oauth.js"; +import { ANTIGRAVITY_CONFIG, getOAuthClientMetadata } from "../constants/oauth.js"; import { getServerCredentials } from "../config/index.js"; import { startLocalServer } from "../utils/server.js"; import { spinner as createSpinner } from "../utils/ui.js"; @@ -92,14 +92,10 @@ export class AntigravityService { /** * Get metadata object for loadCodeAssist / onboardUser API calls. - * Uses string enum values matching CLIProxyAPI Go source. + * Uses numeric enum values matching Antigravity binary ClientMetadata. */ getMetadata() { - return { - ideType: "IDE_UNSPECIFIED", - platform: "PLATFORM_UNSPECIFIED", - pluginType: "GEMINI", - }; + return getOAuthClientMetadata(); } /**