feat(s2a_service): Add pure API authorization mode without browser
- Add S2A_API_MODE configuration option to enable browser-less authorization - Implement S2AApiAuthorizer class using curl_cffi for browser fingerprint simulation - Add Sentinel PoW (Proof of Work) solver with FNV-1a hashing algorithm - Implement OAuth flow via direct API calls instead of browser automation - Add s2a_api_authorize() function to handle email/password authentication - Support proxy configuration for API requests - Add requirements token generation for API authentication - Update browser_automation.py to check S2A_API_MODE and route to API or browser flow - Update config.py to load S2A_API_MODE from configuration - Add api_mode option to config.toml.example with documentation - Improves performance and stability by eliminating browser overhead while maintaining compatibility with existing browser-based flow
This commit is contained in:
@@ -312,7 +312,7 @@ def reload_config() -> dict:
|
||||
global GPTMAIL_API_KEYS, GPTMAIL_DOMAINS, GPTMAIL_PREFIX
|
||||
global PROXY_ENABLED, PROXIES
|
||||
global S2A_API_BASE, S2A_ADMIN_KEY, S2A_ADMIN_TOKEN
|
||||
global S2A_CONCURRENCY, S2A_PRIORITY, S2A_GROUP_NAMES, S2A_GROUP_IDS
|
||||
global S2A_CONCURRENCY, S2A_PRIORITY, S2A_GROUP_NAMES, S2A_GROUP_IDS, S2A_API_MODE
|
||||
global CONCURRENT_ENABLED, CONCURRENT_WORKERS
|
||||
|
||||
result = {
|
||||
@@ -387,6 +387,7 @@ def reload_config() -> dict:
|
||||
S2A_PRIORITY = _s2a.get("priority", 50)
|
||||
S2A_GROUP_NAMES = _s2a.get("group_names", [])
|
||||
S2A_GROUP_IDS = _s2a.get("group_ids", [])
|
||||
S2A_API_MODE = _s2a.get("api_mode", False)
|
||||
|
||||
except Exception as e:
|
||||
errors.append(f"config.toml: {e}")
|
||||
@@ -619,6 +620,7 @@ S2A_CONCURRENCY = _s2a.get("concurrency", 10)
|
||||
S2A_PRIORITY = _s2a.get("priority", 50)
|
||||
S2A_GROUP_NAMES = _s2a.get("group_names", [])
|
||||
S2A_GROUP_IDS = _s2a.get("group_ids", [])
|
||||
S2A_API_MODE = _s2a.get("api_mode", False) # 是否使用纯 API 授权模式 (无需浏览器)
|
||||
|
||||
# 账号
|
||||
_account = _cfg.get("account", {})
|
||||
|
||||
Reference in New Issue
Block a user