{"record":{"id":"684884734d0d3e46","repo":"diegosouzapw/OmniRoute","slug":"exchange-failed","errorCode":"exchange_failed","errorMessage":"Token exchange failed (${res.status}): ${text}","messagePattern":"Token exchange failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"CodexDeviceFlowError","httpStatus":null,"severity":"error","filePath":"src/lib/oauth/codexDeviceFlow.ts","lineNumber":270,"sourceCode":"      method: \"POST\",\n      headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n      body: new URLSearchParams({\n        grant_type: \"authorization_code\",\n        client_id: clientId,\n        code: authorizationCode,\n        code_verifier: codeVerifier,\n        redirect_uri: REDIRECT_URI,\n      }).toString(),\n      signal,\n    });\n  } catch (e: any) {\n    if (e?.name === \"AbortError\") throw new CodexDeviceFlowError(\"aborted\", \"Device flow aborted\");\n    throw new CodexDeviceFlowError(\"network\", `Token exchange failed: ${e?.message || e}`);\n  }\n\n  if (!res.ok) {\n    const text = await res.text().catch(() => \"\");\n    throw new CodexDeviceFlowError(\n      \"exchange_failed\",\n      `Token exchange failed (${res.status}): ${text}`,\n      res.status\n    );\n  }\n\n  const data: any = await res.json();\n  if (!data.access_token) {\n    throw new CodexDeviceFlowError(\"exchange_failed\", \"Token exchange returned no access_token\");\n  }\n  return {\n    access_token: data.access_token,\n    refresh_token: data.refresh_token,\n    id_token: data.id_token,\n    expires_in: data.expires_in,\n  };\n}\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/codexDeviceFlow.ts#L252-L288","documentation":"Error \"Token exchange failed (${res.status}): ${text}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/codexDeviceFlow.ts:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}