MCPcopy Create free account
hub / github.com/freecodexyz/free-code / refreshCodexToken

Function refreshCodexToken

src/services/oauth/codex-client.ts:198–219  ·  view source on GitHub ↗
(refreshToken: string)

Source from the content-addressed store, hash-verified

196 * Refreshes an expired Codex access token.
197 */
198export async function refreshCodexToken(refreshToken: string): Promise<CodexTokens> {
199 const result = await postToTokenUrl(
200 new URLSearchParams({
201 grant_type: 'refresh_token',
202 refresh_token: refreshToken,
203 client_id: CODEX_CLIENT_ID,
204 }),
205 )
206 if (result.type !== 'success') {
207 throw new Error('Codex token refresh failed. Please re-login.')
208 }
209 const accountId = extractCodexAccountId(result.access)
210 if (!accountId) {
211 throw new Error('Failed to extract accountId from refreshed Codex token.')
212 }
213 return {
214 accessToken: result.access,
215 refreshToken: result.refresh,
216 expiresAt: result.expires,
217 accountId,
218 }
219}
220
221// ── Local Callback Server ─────────────────────────────────────────────────────
222

Callers

nothing calls this directly

Calls 2

postToTokenUrlFunction · 0.85
extractCodexAccountIdFunction · 0.85

Tested by

no test coverage detected