Download internal/auth/iflow/iflow_token.go from shimen/API: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/shimen/API/resolve/main/internal/auth/iflow/iflow_token.go
- Command line
-
hf download hf://spaces/shimen/API/internal/auth/iflow/iflow_token.go
-
curl -L -o iflow_token.go https://huggingface.co/spaces/shimen/API/resolve/main/internal/auth/iflow/iflow_token.go
1.27 kB
| package iflow | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "os" | |
| "path/filepath" | |
| "github.com/router-for-me/CLIProxyAPI/v6/internal/misc" | |
| ) | |
| // IFlowTokenStorage persists iFlow OAuth credentials alongside the derived API key. | |
| type IFlowTokenStorage struct { | |
| AccessToken string `json:"access_token"` | |
| RefreshToken string `json:"refresh_token"` | |
| LastRefresh string `json:"last_refresh"` | |
| Expire string `json:"expired"` | |
| APIKey string `json:"api_key"` | |
| Email string `json:"email"` | |
| TokenType string `json:"token_type"` | |
| Scope string `json:"scope"` | |
| Cookie string `json:"cookie"` | |
| Type string `json:"type"` | |
| } | |
| // SaveTokenToFile serialises the token storage to disk. | |
| func (ts *IFlowTokenStorage) SaveTokenToFile(authFilePath string) error { | |
| misc.LogSavingCredentials(authFilePath) | |
| ts.Type = "iflow" | |
| if err := os.MkdirAll(filepath.Dir(authFilePath), 0o700); err != nil { | |
| return fmt.Errorf("iflow token: create directory failed: %w", err) | |
| } | |
| f, err := os.Create(authFilePath) | |
| if err != nil { | |
| return fmt.Errorf("iflow token: create file failed: %w", err) | |
| } | |
| defer func() { _ = f.Close() }() | |
| if err = json.NewEncoder(f).Encode(ts); err != nil { | |
| return fmt.Errorf("iflow token: encode token failed: %w", err) | |
| } | |
| return nil | |
| } | |