feat(webui): support remote Codex OAuth login (#5174)

This commit is contained in:
chengyongru
2026-07-30 15:06:34 +08:00
committed by GitHub
parent e2563e2e74
commit 606ac56e8f
22 changed files with 1233 additions and 150 deletions
+10 -2
View File
@@ -61,6 +61,7 @@ function isSlashCommandLifecycle(value: unknown): value is SlashCommandLifecycle
const CHANNEL_VALUES_HEADER = "X-Nanobot-Channel-Values";
const API_SERVICE_VALUES_HEADER = "X-Nanobot-API-Service-Values";
const OAUTH_CODE_HEADER = "X-Nanobot-OAuth-Code";
const OAUTH_CALLBACK_HEADER = "X-Nanobot-OAuth-Callback";
const PROVIDER_VALUES_HEADER = "X-Nanobot-Provider-Values";
export class ApiError extends Error {
@@ -992,9 +993,11 @@ export async function loginProviderOAuth(
token: string,
provider: string,
base: string = "",
remoteBrowserAccess: boolean = false,
): Promise<ProviderOAuthLoginResult> {
const query = new URLSearchParams();
query.set("provider", provider);
if (remoteBrowserAccess) query.set("remote_browser", "true");
return request<ProviderOAuthLoginResult>(
`${base}/api/settings/provider/oauth-login?${query}`,
token,
@@ -1006,13 +1009,18 @@ export async function completeProviderOAuth(
token: string,
provider: string,
flowId: string,
authorizationCode?: string,
authorizationResponse?: string,
base: string = "",
): Promise<ProviderOAuthCompletionResult> {
const query = new URLSearchParams();
query.set("provider", provider);
query.set("flow_id", flowId);
const headers = authorizationCode ? { [OAUTH_CODE_HEADER]: authorizationCode } : undefined;
const responseHeader = provider === "openai_codex"
? OAUTH_CALLBACK_HEADER
: OAUTH_CODE_HEADER;
const headers = authorizationResponse
? { [responseHeader]: authorizationResponse }
: undefined;
return request<ProviderOAuthCompletionResult>(
`${base}/api/settings/provider/oauth-login/complete?${query}`,
token,
+1
View File
@@ -458,6 +458,7 @@ export interface ProviderOAuthAuthorizationRequired {
flow_id: string;
authorization_url: string;
expires_in: number;
completion_input?: "authorization_code" | "callback_url";
}
export interface ProviderOAuthPending {