Files
CLIProxyAPI/sdk/auth/oauth_callback.go
Supra4E8C 93414f1baa feat (auth): CLI OAuth supports pasting callback URLs to complete login
- 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
2025-12-20 18:25:55 +08:00

42 lines
754 B
Go

package auth
import (
"fmt"
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
)
func promptForOAuthCallback(prompt func(string) (string, error), provider string) (<-chan *misc.OAuthCallback, <-chan error) {
if prompt == nil {
return nil, nil
}
resultCh := make(chan *misc.OAuthCallback, 1)
errCh := make(chan error, 1)
go func() {
label := provider
if label == "" {
label = "OAuth"
}
input, err := prompt(fmt.Sprintf("Paste the %s callback URL (or press Enter to keep waiting): ", label))
if err != nil {
errCh <- err
return
}
parsed, err := misc.ParseOAuthCallback(input)
if err != nil {
errCh <- err
return
}
if parsed == nil {
return
}
resultCh <- parsed
}()
return resultCh, errCh
}