MCPcopy
hub / github.com/codeaashu/claude-code / checkAndRefreshOAuthTokenIfNeeded

Function checkAndRefreshOAuthTokenIfNeeded

src/utils/auth.ts:1427–1445  ·  view source on GitHub ↗
(
  retryCount = 0,
  force = false,
)

Source from the content-addressed store, hash-verified

1425let pendingRefreshCheck: Promise<boolean> | null = null
1426
1427export function checkAndRefreshOAuthTokenIfNeeded(
1428 retryCount = 0,
1429 force = false,
1430): Promise<boolean> {
1431 // Deduplicate concurrent non-retry, non-force calls
1432 if (retryCount === 0 && !force) {
1433 if (pendingRefreshCheck) {
1434 return pendingRefreshCheck
1435 }
1436
1437 const promise = checkAndRefreshOAuthTokenIfNeededImpl(retryCount, force)
1438 pendingRefreshCheck = promise.finally(() => {
1439 pendingRefreshCheck = null
1440 })
1441 return pendingRefreshCheck
1442 }
1443
1444 return checkAndRefreshOAuthTokenIfNeededImpl(retryCount, force)
1445}
1446
1447async function checkAndRefreshOAuthTokenIfNeededImpl(
1448 retryCount: number,

Callers 15

runFunction · 0.85
callFunction · 0.85
submitFeedbackFunction · 0.85
submitTranscriptShareFunction · 0.85
teleportToRemoteFunction · 0.85
handleOAuth401ErrorImplFunction · 0.85
validateForceLoginOrgFunction · 0.85
checkNeedsClaudeAiLoginFunction · 0.85
initReplBridgeFunction · 0.85
bridgeMainFunction · 0.85
connectVoiceStreamFunction · 0.85

Tested by

no test coverage detected