Fix Antigravity OAuth
This commit is contained in:
parent
f2306e6962
commit
11b2fcd643
5 changed files with 41 additions and 49 deletions
|
|
@ -97,7 +97,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",
|
||||
loadCodeAssistClientMetadata: JSON.stringify({ ideType: 9, platform: getOAuthPlatformEnum(), pluginType: 2 }),
|
||||
// String enum matches CLIProxyAPI Go source (internal/auth/antigravity/constants.go)
|
||||
loadCodeAssistClientMetadata: JSON.stringify({ ideType: "IDE_UNSPECIFIED", platform: "PLATFORM_UNSPECIFIED", pluginType: "GEMINI" }),
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import {
|
|||
KIMI_CODING_CONFIG,
|
||||
KILOCODE_CONFIG,
|
||||
CLINE_CONFIG,
|
||||
getOAuthClientMetadata,
|
||||
} from "./constants/oauth";
|
||||
|
||||
// Provider configurations
|
||||
|
|
@ -255,21 +254,22 @@ const PROVIDERS = {
|
|||
return await response.json();
|
||||
},
|
||||
postExchange: async (tokens) => {
|
||||
const headers = {
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
// Matches CLIProxyAPI Go source: string enum, no mode field
|
||||
const loadHeaders = {
|
||||
"Authorization": `Bearer ${tokens.access_token}`,
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": ANTIGRAVITY_CONFIG.loadCodeAssistUserAgent,
|
||||
"X-Goog-Api-Client": ANTIGRAVITY_CONFIG.loadCodeAssistApiClient,
|
||||
"Client-Metadata": ANTIGRAVITY_CONFIG.loadCodeAssistClientMetadata,
|
||||
"x-request-source": "local", // MITM passthrough marker
|
||||
"x-request-source": "local",
|
||||
};
|
||||
const metadata = getOAuthClientMetadata();
|
||||
const metadata = { ideType: "IDE_UNSPECIFIED", platform: "PLATFORM_UNSPECIFIED", pluginType: "GEMINI" };
|
||||
|
||||
// Fetch user info
|
||||
const userInfoRes = await fetch(`${ANTIGRAVITY_CONFIG.userInfoUrl}?alt=json`, {
|
||||
headers: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
"x-request-source": "local", // MITM passthrough marker
|
||||
"x-request-source": "local",
|
||||
},
|
||||
});
|
||||
const userInfo = userInfoRes.ok ? await userInfoRes.json() : {};
|
||||
|
|
@ -280,13 +280,12 @@ const PROVIDERS = {
|
|||
try {
|
||||
const loadRes = await fetch(ANTIGRAVITY_CONFIG.loadCodeAssistEndpoint, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({ metadata, mode: 1 }),
|
||||
headers: loadHeaders,
|
||||
body: JSON.stringify({ metadata }),
|
||||
});
|
||||
if (loadRes.ok) {
|
||||
const data = await loadRes.json();
|
||||
projectId = data.cloudaicompanionProject?.id || data.cloudaicompanionProject || "";
|
||||
// Extract tier ID
|
||||
if (Array.isArray(data.allowedTiers)) {
|
||||
for (const tier of data.allowedTiers) {
|
||||
if (tier.isDefault && tier.id) {
|
||||
|
|
@ -307,8 +306,8 @@ const PROVIDERS = {
|
|||
try {
|
||||
const onboardRes = await fetch(ANTIGRAVITY_CONFIG.onboardUserEndpoint, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({ tierId, metadata, cloudaicompanionProject: projectId, mode: 1 }),
|
||||
headers: loadHeaders,
|
||||
body: JSON.stringify({ tierId, metadata }),
|
||||
});
|
||||
if (onboardRes.ok) {
|
||||
const result = await onboardRes.json();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import crypto from "crypto";
|
||||
import { platform, arch } from "os";
|
||||
import open from "open";
|
||||
import { ANTIGRAVITY_CONFIG } from "../constants/oauth.js";
|
||||
import { getServerCredentials } from "../config/index.js";
|
||||
|
|
@ -92,21 +91,14 @@ export class AntigravityService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get metadata object for API calls
|
||||
* Uses numeric enum values matching Antigravity binary specifications
|
||||
* Get metadata object for loadCodeAssist / onboardUser API calls.
|
||||
* Uses string enum values matching CLIProxyAPI Go source.
|
||||
*/
|
||||
getMetadata() {
|
||||
const os = platform();
|
||||
const architecture = arch();
|
||||
let platformEnum = 0; // UNSPECIFIED
|
||||
if (os === "darwin") platformEnum = architecture === "arm64" ? 2 : 1;
|
||||
else if (os === "linux") platformEnum = architecture === "arm64" ? 4 : 3;
|
||||
else if (os === "win32") platformEnum = 5;
|
||||
|
||||
return {
|
||||
ideType: 9, // ANTIGRAVITY
|
||||
platform: platformEnum,
|
||||
pluginType: 2, // GEMINI
|
||||
ideType: "IDE_UNSPECIFIED",
|
||||
platform: "PLATFORM_UNSPECIFIED",
|
||||
pluginType: "GEMINI",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +109,7 @@ export class AntigravityService {
|
|||
const response = await fetch(this.config.loadCodeAssistEndpoint, {
|
||||
method: "POST",
|
||||
headers: this.getApiHeaders(accessToken),
|
||||
body: JSON.stringify({ metadata: this.getMetadata(), mode: 1 }),
|
||||
body: JSON.stringify({ metadata: this.getMetadata() }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -154,12 +146,7 @@ export class AntigravityService {
|
|||
const response = await fetch(this.config.onboardUserEndpoint, {
|
||||
method: "POST",
|
||||
headers: this.getApiHeaders(accessToken),
|
||||
body: JSON.stringify({
|
||||
tierId,
|
||||
metadata: this.getMetadata(),
|
||||
cloudaicompanionProject: projectId,
|
||||
mode: 1,
|
||||
}),
|
||||
body: JSON.stringify({ tierId, metadata: this.getMetadata() }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue