mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
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
This commit is contained in:
41
sdk/auth/oauth_callback.go
Normal file
41
sdk/auth/oauth_callback.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user