MCPcopy Create free account
hub / github.com/anomalyco/opencode / refreshAccessToken

Function refreshAccessToken

packages/opencode/src/plugin/openai/codex.ts:125–139  ·  view source on GitHub ↗
(refreshToken: string, issuer = ISSUER)

Source from the content-addressed store, hash-verified

123}
124
125async function refreshAccessToken(refreshToken: string, issuer = ISSUER): Promise<TokenResponse> {
126 const response = await fetch(`${issuer}/oauth/token`, {
127 method: "POST",
128 headers: { "Content-Type": "application/x-www-form-urlencoded" },
129 body: new URLSearchParams({
130 grant_type: "refresh_token",
131 refresh_token: refreshToken,
132 client_id: CLIENT_ID,
133 }).toString(),
134 })
135 if (!response.ok) {
136 throw new Error(`Token refresh failed: ${response.status}`)
137 }
138 return response.json()
139}
140
141// Kept as a named export for plugin.codex tests; delegates to the shared branded page.
142export const renderOAuthError = (error: string) => OauthCallbackPage.error(error, { provider: "ChatGPT" })

Callers 1

fetchFunction · 0.70

Calls 2

fetchFunction · 0.70
jsonMethod · 0.65

Tested by

no test coverage detected