diff --git a/frontend/src/api/admin/accounts.ts b/frontend/src/api/admin/accounts.ts index 751da25f..d9b537d8 100644 --- a/frontend/src/api/admin/accounts.ts +++ b/frontend/src/api/admin/accounts.ts @@ -550,14 +550,18 @@ export async function getAntigravityDefaultModelMapping(): Promise> { - const payload: { refresh_token: string; proxy_id?: number } = { + const payload: { refresh_token: string; proxy_id?: number; client_id?: string } = { refresh_token: refreshToken } if (proxyId) { payload.proxy_id = proxyId } + if (clientId) { + payload.client_id = clientId + } const { data } = await apiClient.post>(endpoint, payload) return data } diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 6f02a9d9..cff7ae1c 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -2504,6 +2504,7 @@ :allow-multiple="form.platform === 'anthropic'" :show-cookie-option="form.platform === 'anthropic'" :show-refresh-token-option="form.platform === 'openai' || form.platform === 'sora' || form.platform === 'antigravity'" + :show-mobile-refresh-token-option="form.platform === 'openai'" :show-session-token-option="form.platform === 'sora'" :show-access-token-option="form.platform === 'sora'" :platform="form.platform" @@ -2511,6 +2512,7 @@ @generate-url="handleGenerateUrl" @cookie-auth="handleCookieAuth" @validate-refresh-token="handleValidateRefreshToken" + @validate-mobile-refresh-token="handleOpenAIValidateMobileRT" @validate-session-token="handleValidateSessionToken" @import-access-token="handleImportAccessToken" /> @@ -4360,11 +4362,14 @@ const handleOpenAIExchange = async (authCode: string) => { } // OpenAI 手动 RT 批量验证和创建 -const handleOpenAIValidateRT = async (refreshTokenInput: string) => { +// OpenAI Mobile RT 使用的 client_id(与后端 openai.SoraClientID 一致) +const OPENAI_MOBILE_RT_CLIENT_ID = 'app_LlGpXReQgckcGGUo2JrYvtJK' + +// OpenAI/Sora RT 批量验证和创建(共享逻辑) +const handleOpenAIBatchRT = async (refreshTokenInput: string, clientId?: string) => { const oauthClient = activeOpenAIOAuth.value if (!refreshTokenInput.trim()) return - // Parse multiple refresh tokens (one per line) const refreshTokens = refreshTokenInput .split('\n') .map((rt) => rt.trim()) @@ -4389,7 +4394,8 @@ const handleOpenAIValidateRT = async (refreshTokenInput: string) => { try { const tokenInfo = await oauthClient.validateRefreshToken( refreshTokens[i], - form.proxy_id + form.proxy_id, + clientId ) if (!tokenInfo) { failedCount++ @@ -4399,6 +4405,9 @@ const handleOpenAIValidateRT = async (refreshTokenInput: string) => { } const credentials = oauthClient.buildCredentials(tokenInfo) + if (clientId) { + credentials.client_id = clientId + } const oauthExtra = oauthClient.buildExtraInfo(tokenInfo) as Record | undefined const extra = buildOpenAIExtra(oauthExtra) @@ -4410,8 +4419,9 @@ const handleOpenAIValidateRT = async (refreshTokenInput: string) => { } } - // Generate account name with index for batch - const accountName = refreshTokens.length > 1 ? `${form.name} #${i + 1}` : form.name + // Generate account name; fallback to email if name is empty (ent schema requires NotEmpty) + const baseName = form.name || tokenInfo.email || 'OpenAI OAuth Account' + const accountName = refreshTokens.length > 1 ? `${baseName} #${i + 1}` : baseName let openaiAccountId: string | number | undefined @@ -4494,6 +4504,12 @@ const handleOpenAIValidateRT = async (refreshTokenInput: string) => { } } +// 手动输入 RT(Codex CLI client_id,默认) +const handleOpenAIValidateRT = (rt: string) => handleOpenAIBatchRT(rt) + +// 手动输入 Mobile RT(SoraClientID) +const handleOpenAIValidateMobileRT = (rt: string) => handleOpenAIBatchRT(rt, OPENAI_MOBILE_RT_CLIENT_ID) + // Sora 手动 ST 批量验证和创建 const handleSoraValidateST = async (sessionTokenInput: string) => { const oauthClient = activeOpenAIOAuth.value diff --git a/frontend/src/components/account/OAuthAuthorizationFlow.vue b/frontend/src/components/account/OAuthAuthorizationFlow.vue index cc74f8ce..b4c299db 100644 --- a/frontend/src/components/account/OAuthAuthorizationFlow.vue +++ b/frontend/src/components/account/OAuthAuthorizationFlow.vue @@ -48,6 +48,17 @@ t(getOAuthKey('refreshTokenAuth')) }} +