MCPcopy Index your code
hub / github.com/anomalyco/opencode / refreshAccessToken

Function refreshAccessToken

packages/opencode/src/plugin/xai.ts:167–182  ·  view source on GitHub ↗
(refreshToken: string, options: XaiAuthPluginOptions = {})

Source from the content-addressed store, hash-verified

165}
166
167async function refreshAccessToken(refreshToken: string, options: XaiAuthPluginOptions = {}): Promise<TokenResponse> {
168 const response = await fetch(options.tokenUrl ?? TOKEN_URL, {
169 method: "POST",
170 headers: authHeaders(),
171 body: new URLSearchParams({
172 grant_type: "refresh_token",
173 refresh_token: refreshToken,
174 client_id: CLIENT_ID,
175 }).toString(),
176 })
177 if (!response.ok) {
178 const detail = await response.text().catch(() => "")
179 throw new Error(`xAI token refresh failed (${response.status})${detail ? `: ${detail}` : ""}`)
180 }
181 return response.json() as Promise<TokenResponse>
182}
183
184export interface DeviceCodeResponse {
185 device_code: string

Callers 1

fetchFunction · 0.70

Calls 4

fetchFunction · 0.70
authHeadersFunction · 0.70
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected