{"record":{"id":"23689645c5402982","repo":"diegosouzapw/OmniRoute","slug":"xai-token-exchange-failed-error","errorCode":null,"errorMessage":"xAI token exchange failed: ${error}","messagePattern":"xAI token exchange failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/providers/xai-oauth.ts","lineNumber":81,"sourceCode":"  exchangeToken: async (config, code, redirectUri, codeVerifier) => {\n    const response = await fetch(config.tokenUrl, {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/x-www-form-urlencoded\",\n        Accept: \"application/json\",\n      },\n      body: new URLSearchParams({\n        grant_type: \"authorization_code\",\n        client_id: config.clientId,\n        code,\n        redirect_uri: redirectUri,\n        code_verifier: codeVerifier,\n      }),\n    });\n\n    if (!response.ok) {\n      const error = await response.text();\n      throw new Error(`xAI token exchange failed: ${error}`);\n    }\n\n    return response.json();\n  },\n\n  mapTokens: (tokens) => {\n    const identity = decodeXaiIdTokenIdentity(tokens.id_token);\n    return {\n      accessToken: tokens.access_token,\n      refreshToken: tokens.refresh_token,\n      idToken: tokens.id_token,\n      expiresIn: tokens.expires_in,\n      email: identity.email,\n      name: identity.name || identity.email,\n      providerSpecificData: {\n        scope: tokens.scope || XAI_OAUTH_CONFIG.scope,\n        tokenType: tokens.token_type || \"Bearer\",\n      },","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/providers/xai-oauth.ts#L63-L99","documentation":"Error \"xAI token exchange failed: ${error}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/providers/xai-oauth.ts:81 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"}