decolua/9router · error · Error
No Codex access token available. Please re-authorize the con
Error message
No Codex access token available. Please re-authorize the connection.
What it means
getCodexRateLimitResetCredits requires a Codex OAuth access token to call the reset-credits endpoint. When called with an empty/undefined accessToken it throws immediately with this message, instructing the user to re-authorize. It is a guard against calling the API without credentials.
Source
Thrown at open-sse/services/usage/codex.js:140
appendCodexQuotaWindows(quotas, "review", reviewRateLimit);
appendCodexQuotaWindows(quotas, "spark", sparkRateLimit);
return {
plan: data.plan_type || data.summary?.plan || "unknown",
limitReached: getCodexRateLimitBody(normalRateLimit)?.limit_reached || false,
reviewLimitReached: getCodexRateLimitBody(reviewRateLimit)?.limit_reached || false,
sparkLimitReached: getCodexRateLimitBody(sparkRateLimit)?.limit_reached || false,
resetCredits: { availableCount: availableResetCredits },
quotas,
};
} catch (error) {
throw new Error(`Failed to fetch Codex usage: ${error.message}`);
}
}
export async function getCodexRateLimitResetCredits(accessToken, proxyOptions = null, providerSpecificData = null) {
if (!accessToken) {
throw new Error("No Codex access token available. Please re-authorize the connection.");
}
const accountId = getCodexAccountId(providerSpecificData);
const headers = {
"Authorization": `Bearer ${accessToken}`,
"Accept": "application/json",
"OpenAI-Beta": "codex-1",
"originator": "codex_cli_rs",
};
if (accountId) headers["ChatGPT-Account-ID"] = accountId;
const response = await proxyAwareFetch(CODEX_CONFIG.resetCreditsUrl, {
method: "GET",
headers,
}, proxyOptions);
let data = null;
try {View on GitHub (pinned to 90b52e06ff)
Solutions
- Re-authorize the Codex connection through the dashboard OAuth flow to obtain a new access token
- Check that the connection's stored credentials were not wiped (tokenRefresh / oauthCredentialManager state)
- Guard the call site: skip the reset-credits fetch when no token exists instead of letting it throw
- If the token should exist, check refresh logs for the failure that left it empty
Example fix
// before
const credits = await getCodexRateLimitResetCredits(accessToken);
// after
if (!accessToken) {
throw new Error("Codex connection is not authorized; run the OAuth flow first.");
}
const credits = await getCodexRateLimitResetCredits(accessToken); Defensive patterns
Strategy: validation
Validate before calling
if (typeof accessToken !== 'string' || !accessToken) {
// skip the call or trigger the OAuth flow instead of hitting the API
return { availableCount: 0, credits: [], notAuthorized: true };
} Type guard
function hasCodexToken(t) { return typeof t === 'string' && t.length > 0; } Try / catch
try {
credits = await getCodexRateLimitResetCredits(accessToken, proxyOptions, data);
} catch (e) {
if (e.message.includes('re-authorize')) {
return startCodexReauthFlow(); // surface reconnect UI to the user
}
throw e;
} Prevention
- Check connection authorization state in the dashboard before rendering reset-credit features
- Run the Codex OAuth flow at setup and store the token via oauthCredentialManager
- Treat this error as 'needs reconnect', not a bug — the message tells the user exactly that
- Monitor token refresh job failures so an empty token is caught before API calls
When it happens
Trigger: getCodexRateLimitResetCredits is invoked with a null/empty access token — the Codex connection was never authorized, the stored token was cleared, or the token-refresh step failed upstream and null was passed through.
Common situations: User never completed Codex (ChatGPT) OAuth; credentials deleted from the dashboard; refresh flow failed leaving no token on the connection.
Related errors
- Kiro tool input must be a JSON object
- Vertex: failed to mint access token from Service Account JSO
- Vertex: failed to refresh access token from ADC JSON (author
- No GitHub access token available. Please re-authorize the co
- cosy: user id is empty
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/174862e5bed743b4.
Report an issue: GitHub.