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

Function refreshAccessToken

packages/opencode/src/plugin/snowflake-cortex.ts:136–158  ·  view source on GitHub ↗
(account: string, refreshToken: string)

Source from the content-addressed store, hash-verified

134}
135
136async function refreshAccessToken(account: string, refreshToken: string) {
137 const response = await fetch(`https://${account}.snowflakecomputing.com/oauth/token-request`, {
138 method: "POST",
139 headers: {
140 ...authHeaders(),
141 Authorization: authBasicHeader(),
142 },
143 body: new URLSearchParams({
144 grant_type: "refresh_token",
145 refresh_token: refreshToken,
146 client_id: OAUTH_CLIENT_ID,
147 }).toString(),
148 })
149
150 if (!response.ok) {
151 const detail = await response.text().catch(() => "")
152 throw new Error(`Snowflake token refresh failed (${response.status})${detail ? `: ${detail}` : ""}`)
153 }
154
155 const token = (await response.json()) as TokenResponse
156 if (!token.access_token) throw new Error("Snowflake refresh response did not include access_token")
157 return token
158}
159
160async function startOAuthServer() {
161 if (oauthServer) return

Callers 2

loaderFunction · 0.70
refreshFunction · 0.70

Calls 5

authBasicHeaderFunction · 0.85
fetchFunction · 0.70
authHeadersFunction · 0.70
textMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected