Significant-Gravitas/AutoGPT · error · Error
Failed to start OAuth flow
Error message
Failed to start OAuth flow
What it means
Raised by approve_transfer when the caller's active org matches neither the transfer's sourceOrganizationId nor its targetOrganizationId. Only the two participating orgs may approve; every other org is rejected with a ValueError.
Source
Thrown at autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts:70
setIsGoogleLoading(true);
setIsLoggingIn(true);
try {
// Include next URL in OAuth flow if present
const callbackUrl = nextUrl
? `/auth/callback?next=${encodeURIComponent(nextUrl)}`
: `/auth/callback`;
const fullCallbackUrl = `${window.location.origin}${callbackUrl}`;
const response = await fetch("/api/auth/login/with-provider", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ provider, redirectTo: fullCallbackUrl }),
});
if (!response.ok) {
const { error } = await response.json();
throw new Error(error || "Failed to start OAuth flow");
}
const { url } = await response.json();
if (url) window.location.href = url as string;
} catch (error) {
setIsGoogleLoading(false);
setIsLoggingIn(false);
setFeedback(
error instanceof Error ? error.message : "Failed to start OAuth flow",
);
}
}
async function handleLogin(data: z.infer<typeof loginFormSchema>) {
setIsLoading(true);
setIsLoggingIn(true);
if (data.email.includes("@agpt.co")) {View on GitHub (pinned to 9c8bb5550f)
Solutions
- Verify the active org matches one of the transfer's parties (source/target) before calling approve; prompt the user to switch org if they belong to one of them.
- Ensure the frontend passes the currently selected org consistently on every transfers call.
- Surface which orgs are parties in the error detail so the user knows which org to switch to.
Example fix
# before
await approve_transfer(tid, user_id, active_org_id)
# after
tr = await get_transfer(tid)
if active_org_id not in (tr.source_org_id, tr.target_org_id):
raise PermissionError("Switch to a participating org to approve")
await approve_transfer(tid, user_id, active_org_id) Defensive patterns
Strategy: type-guard
Validate before calling
tr = await get_transfer(transfer_id) assert org_id in (tr.source_org_id, tr.target_org_id), "Switch to a participating org"
Type guard
def org_is_party(tr: TransferResponse, org_id: str) -> bool:
return org_id in (tr.source_org_id, tr.target_org_id) Try / catch
try:
await approve_transfer(tid, user_id, org_id)
except ValueError as e:
if "not a party" in str(e):
prompt_org_switch(tr)
else:
raise Prevention
- Always send the currently selected org with transfers calls
- Prompt an org switch when the user belongs to a party org but has another active
- Show party org names in the transfer list
When it happens
Trigger: Thrown at autogpt_platform/frontend/src/app/(no-navbar)/login/useLoginPage.ts:70 when the library encounters an invalid state.
Common situations: Multi-org users forgetting to switch active org in the UI; frontend sending a stale active-org ID after the user switched orgs; copying a transfer URL and approving from an unrelated account.
Related errors
- Failed to fetch rate limit
- Unsupported import in artifact preview: ${name}
- PKCE verifier not found in session
- Token exchange failed
- Login failed
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/1bb49b6bf78591f3.
Report an issue: GitHub.