feat(auth): Enhance Gemini web auth with flexible input and UI

This commit is contained in:
hkfires
2025-09-26 09:43:26 +08:00
parent 3297f75edd
commit f228a4dcca
2 changed files with 97 additions and 67 deletions

View File

@@ -128,6 +128,7 @@ func (a *Auth) AccountInfo() (string, string) {
if a == nil {
return "", ""
}
// For Gemini Web, prefer explicit cookie label for stability.
if strings.ToLower(a.Provider) == "gemini-web" {
// Prefer explicit label written into auth file (e.g., gemini-web-<hash>)
if a.Metadata != nil {
@@ -145,6 +146,22 @@ func (a *Auth) AccountInfo() (string, string) {
}
}
}
// For Gemini CLI, include project ID in the OAuth account info if present.
if strings.ToLower(a.Provider) == "gemini-cli" {
if a.Metadata != nil {
email, _ := a.Metadata["email"].(string)
email = strings.TrimSpace(email)
if email != "" {
if p, ok := a.Metadata["project_id"].(string); ok {
p = strings.TrimSpace(p)
if p != "" {
return "oauth", email + " (" + p + ")"
}
}
return "oauth", email
}
}
}
if a.Metadata != nil {
if v, ok := a.Metadata["email"].(string); ok {
return "oauth", v