mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
- Added callback URL resolution and terminal prompt logic - Codex/Claude/iFlow/Antigravity/Gemini login supports callback URL or local callback completion - Update Gemini login option signature and manager call - CLI default prompt function is compatible with null input to continue waiting
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// DoAntigravityLogin triggers the OAuth flow for the antigravity provider and saves tokens.
|
|
func DoAntigravityLogin(cfg *config.Config, options *LoginOptions) {
|
|
if options == nil {
|
|
options = &LoginOptions{}
|
|
}
|
|
|
|
promptFn := options.Prompt
|
|
if promptFn == nil {
|
|
promptFn = defaultProjectPrompt()
|
|
}
|
|
|
|
manager := newAuthManager()
|
|
authOpts := &sdkAuth.LoginOptions{
|
|
NoBrowser: options.NoBrowser,
|
|
Metadata: map[string]string{},
|
|
Prompt: promptFn,
|
|
}
|
|
|
|
record, savedPath, err := manager.Login(context.Background(), "antigravity", cfg, authOpts)
|
|
if err != nil {
|
|
log.Errorf("Antigravity authentication failed: %v", err)
|
|
return
|
|
}
|
|
|
|
if savedPath != "" {
|
|
fmt.Printf("Authentication saved to %s\n", savedPath)
|
|
}
|
|
if record != nil && record.Label != "" {
|
|
fmt.Printf("Authenticated as %s\n", record.Label)
|
|
}
|
|
fmt.Println("Antigravity authentication successful!")
|
|
}
|