MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / withOAuth401Retry

Function withOAuth401Retry

src/utils/http.ts:143–164  ·  view source on GitHub ↗
(
  request: () => Promise<T>,
  opts?: { also403Revoked?: boolean },
)

Source from the content-addressed store, hash-verified

141 * revoked" body (some endpoints signal revocation this way instead of 401).
142 */
143export async function withOAuth401Retry<T>(
144 request: () => Promise<T>,
145 opts?: { also403Revoked?: boolean },
146): Promise<T> {
147 try {
148 return await request()
149 } catch (err) {
150 if (!axios.isAxiosError(err)) throw err
151 const status = err.response?.status
152 const isAuthError =
153 status === 401 ||
154 (opts?.also403Revoked &&
155 status === 403 &&
156 typeof err.response?.data === 'string' &&
157 err.response.data.includes('OAuth token has been revoked'))
158 if (!isAuthError) throw err
159 const failedAccessToken = getClaudeAIOAuthTokens()?.accessToken
160 if (!failedAccessToken) throw err
161 await handleOAuth401Error(failedAccessToken)
162 return await request()
163 }
164}

Callers 5

grove.tsFile · 0.85
markGroveNoticeViewedFunction · 0.85
updateGroveSettingsFunction · 0.85
fetchBootstrapAPIFunction · 0.85
_checkMetricsEnabledAPIFunction · 0.85

Calls 1

handleOAuth401ErrorFunction · 0.85

Tested by

no test coverage detected