Download internal/cmd/iflow_login.go from shimen/ShinAPI: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/shimen/ShinAPI/resolve/main/internal/cmd/iflow_login.go
- Command line
-
hf download hf://spaces/shimen/ShinAPI/internal/cmd/iflow_login.go
-
curl -L -o iflow_login.go https://huggingface.co/spaces/shimen/ShinAPI/resolve/main/internal/cmd/iflow_login.go
1.13 kB
| package cmd | |
| import ( | |
| "context" | |
| "errors" | |
| "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" | |
| ) | |
| // DoIFlowLogin performs the iFlow OAuth login via the shared authentication manager. | |
| func DoIFlowLogin(cfg *config.Config, options *LoginOptions) { | |
| if options == nil { | |
| options = &LoginOptions{} | |
| } | |
| manager := newAuthManager() | |
| promptFn := options.Prompt | |
| if promptFn == nil { | |
| promptFn = defaultProjectPrompt() | |
| } | |
| authOpts := &sdkAuth.LoginOptions{ | |
| NoBrowser: options.NoBrowser, | |
| CallbackPort: options.CallbackPort, | |
| Metadata: map[string]string{}, | |
| Prompt: promptFn, | |
| } | |
| _, savedPath, err := manager.Login(context.Background(), "iflow", cfg, authOpts) | |
| if err != nil { | |
| var emailErr *sdkAuth.EmailRequiredError | |
| if errors.As(err, &emailErr) { | |
| log.Error(emailErr.Error()) | |
| return | |
| } | |
| fmt.Printf("iFlow authentication failed: %v\n", err) | |
| return | |
| } | |
| if savedPath != "" { | |
| fmt.Printf("Authentication saved to %s\n", savedPath) | |
| } | |
| fmt.Println("iFlow authentication successful!") | |
| } | |