mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 21:10:51 +08:00
feat(antigravity): add FetchAntigravityProjectID function and integrate project ID retrieval
This commit is contained in:
@@ -1472,6 +1472,17 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
projectID := ""
|
||||||
|
if strings.TrimSpace(tokenResp.AccessToken) != "" {
|
||||||
|
fetchedProjectID, errProject := sdkAuth.FetchAntigravityProjectID(ctx, tokenResp.AccessToken, httpClient)
|
||||||
|
if errProject != nil {
|
||||||
|
log.Warnf("antigravity: failed to fetch project ID: %v", errProject)
|
||||||
|
} else {
|
||||||
|
projectID = fetchedProjectID
|
||||||
|
log.Infof("antigravity: obtained project ID %s", projectID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
metadata := map[string]any{
|
metadata := map[string]any{
|
||||||
"type": "antigravity",
|
"type": "antigravity",
|
||||||
@@ -1484,6 +1495,9 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) {
|
|||||||
if email != "" {
|
if email != "" {
|
||||||
metadata["email"] = email
|
metadata["email"] = email
|
||||||
}
|
}
|
||||||
|
if projectID != "" {
|
||||||
|
metadata["project_id"] = projectID
|
||||||
|
}
|
||||||
|
|
||||||
fileName := sanitizeAntigravityFileName(email)
|
fileName := sanitizeAntigravityFileName(email)
|
||||||
label := strings.TrimSpace(email)
|
label := strings.TrimSpace(email)
|
||||||
@@ -1507,6 +1521,9 @@ func (h *Handler) RequestAntigravityToken(c *gin.Context) {
|
|||||||
|
|
||||||
delete(oauthStatus, state)
|
delete(oauthStatus, state)
|
||||||
fmt.Printf("Authentication successful! Token saved to %s\n", savedPath)
|
fmt.Printf("Authentication successful! Token saved to %s\n", savedPath)
|
||||||
|
if projectID != "" {
|
||||||
|
fmt.Printf("Using GCP project: %s\n", projectID)
|
||||||
|
}
|
||||||
fmt.Println("You can now use Antigravity services through this CLI")
|
fmt.Println("You can now use Antigravity services through this CLI")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -320,6 +320,11 @@ const (
|
|||||||
antigravityClientMetadata = `{"ideType":"IDE_UNSPECIFIED","platform":"PLATFORM_UNSPECIFIED","pluginType":"GEMINI"}`
|
antigravityClientMetadata = `{"ideType":"IDE_UNSPECIFIED","platform":"PLATFORM_UNSPECIFIED","pluginType":"GEMINI"}`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FetchAntigravityProjectID exposes project discovery for external callers.
|
||||||
|
func FetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error) {
|
||||||
|
return fetchAntigravityProjectID(ctx, accessToken, httpClient)
|
||||||
|
}
|
||||||
|
|
||||||
// fetchAntigravityProjectID retrieves the project ID for the authenticated user via loadCodeAssist.
|
// fetchAntigravityProjectID retrieves the project ID for the authenticated user via loadCodeAssist.
|
||||||
// This uses the same approach as Gemini CLI to get the cloudaicompanionProject.
|
// This uses the same approach as Gemini CLI to get the cloudaicompanionProject.
|
||||||
func fetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error) {
|
func fetchAntigravityProjectID(ctx context.Context, accessToken string, httpClient *http.Client) (string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user