Unified · Split
| @@ -1472,6 +1472,17 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) { · 1471 unmodified lines | ||
| 1472 | 1472 | } |
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | + projectID := "" | |
| 1476 | + if strings.TrimSpace(tokenResp.AccessToken) != "" { | |
| 1477 | + fetchedProjectID, errProject := sdkAuth.FetchAntigravityProjectID(ctx, tokenResp.AccessToken, httpClient) | |
| 1478 | + if errProject != nil { | |
| 1479 | + log.Warnf("antigravity: failed to fetch project ID: %v", errProject) | |
| 1480 | + } else { | |
| 1481 | + projectID = fetchedProjectID | |
| 1482 | + log.Infof("antigravity: obtained project ID %s", projectID) | |
| 1483 | + } | |
| 1484 | + } | |
| 1485 | + | |
| 1475 | 1486 | now := time.Now() |
| 1476 | 1487 | metadata := map[string]any{ |
| 1477 | 1488 | "type": "antigravity", |
| @@ -1484,6 +1495,9 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) { · 6 unmodified lines | ||
| 1484 | 1495 | if email != "" { |
| 1485 | 1496 | metadata["email"] = email |
| 1486 | 1497 | } |
| 1498 | + if projectID != "" { | |
| 1499 | + metadata["project_id"] = projectID | |
| 1500 | + } | |
| 1487 | 1501 | |
| 1488 | 1502 | fileName := sanitizeAntigravityFileName(email) |
| 1489 | 1503 | label := strings.TrimSpace(email) |
| @@ -1507,6 +1521,9 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) { · 17 unmodified lines | ||
| 1507 | 1521 | |
| 1508 | 1522 | delete(oauthStatus, state) |
| 1509 | 1523 | fmt.Printf("Authentication successful! Token saved to %s\n", savedPath) |
| 1524 | + if projectID != "" { | |
| 1525 | + fmt.Printf("Using GCP project: %s\n", projectID) | |
| 1526 | + } | |
| 1510 | 1527 | fmt.Println("You can now use Antigravity services through this CLI") |
| 1511 | 1528 | }() |
| 1512 | 1529 | |
| @@ -320,6 +320,11 @@ const ( · 319 unmodified lines | ||
| 320 | 320 | antigravityClientMetadata = `{"ideType":"IDE_UNSPECIFIED","platform":"PLATFORM_UNSPECIFIED","pluginType":"GEMINI"}` |
| 321 | 321 | ) |
| 322 | 322 | |
| 323 | +// FetchAntigravityProjectID exposes project discovery for external callers. | |
| 324 | +func FetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error) { | |
| 325 | + return fetchAntigravityProjectID(ctx, accessToken, httpClient) | |
| 326 | +} | |
| 327 | + | |
| 323 | 328 | // fetchAntigravityProjectID retrieves the project ID for the authenticated user via loadCodeAssist. |
| 324 | 329 | // This uses the same approach as Gemini CLI to get the cloudaicompanionProject. |
| 325 | 330 | func fetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error) { |