decolua/9router · error

access_token is required

Error message

access_token is required

What it means

normalizeKiroExternalIdpAuth requires a non-empty access_token (snake_case or camelCase accepted) in the auth document. The access token is the primary Kiro credential and is needed to decode the JWT payload for email/expiry. An empty or missing token aborts the import.

Source

Thrown at src/lib/oauth/kiroExternalIdp.js:104

  if (!input || typeof input !== "object") {
    throw new Error("CLIProxyAPI auth JSON is required");
  }

  const authMethod = normalizeString(input.auth_method || input.authMethod);
  if (authMethod && authMethod !== "external_idp") {
    throw new Error("Only external_idp Kiro auth is supported by this importer");
  }

  const accessToken = normalizeString(input.access_token || input.accessToken);
  const refreshToken = normalizeString(input.refresh_token || input.refreshToken);
  const clientId = normalizeString(input.client_id || input.clientId);
  const tokenEndpoint = validateMicrosoftTokenEndpoint(input.token_endpoint || input.tokenEndpoint);
  const profileArn = normalizeString(input.profile_arn || input.profileArn);
  const region = normalizeString(input.region) || DEFAULT_REGION;
  const scope = normalizeScope(input.scopes || input.scope);

  if (!accessToken) throw new Error("access_token is required");
  if (!refreshToken) throw new Error("refresh_token is required");
  if (!clientId) throw new Error("client_id is required");
  if (!scope) throw new Error("scopes is required");
  if (!profileArn) throw new Error("profile_arn is required");

  const payload = decodeJwtPayload(accessToken);
  const email = input.email || payload?.email || payload?.preferred_username || payload?.upn || payload?.sub || null;

  return {
    accessToken,
    refreshToken,
    expiresAt: resolveExpiresAt(input),
    email,
    providerSpecificData: {
      profileArn,
      region,
      authMethod: "external_idp",
      provider: "CLIProxyAPI",

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Add the access_token (or accessToken) field with the actual Kiro access token JWT
  2. Re-run the external IdP login to obtain a fresh auth document containing access_token
  3. Verify you imported the auth JSON, not a settings/config file
  4. Check for key-name typos — the importer accepts access_token and accessToken only

Example fix

// before
{ "client_id": "...", "refresh_token": "...", "scopes": "openid" }
// after
{ "access_token": "eyJhbGciOi...", "client_id": "...", "refresh_token": "...", "scopes": "openid" }
Defensive patterns

Strategy: validation

Validate before calling

function hasNonEmpty(v, ...keys) { return keys.some(k => typeof v?.[k] === 'string' && v[k].trim()); }
if (!hasNonEmpty(auth, 'access_token', 'accessToken')) throw new Error('access_token missing from Kiro auth');

Type guard

function hasAccessToken(a) {
  return typeof a === 'object' && a !== null &&
    ['access_token', 'accessToken'].some(k => typeof a[k] === 'string' && a[k].trim() !== '');
}

Try / catch

try {
  normalizeKiroExternalIdpAuth(auth);
} catch (e) {
  if (e.message === 'access_token is required') {
    console.error('Auth document has no access_token; re-run the login flow');
  }
  throw e;
}

Prevention

When it happens

Trigger: Auth JSON lacking access_token/accessToken, or where the value is an empty string or whitespace; copying a template file with placeholder fields left blank.

Common situations: Hand-authored auth JSON missing the token; a partially-written auth file from a failed login; the wrong file imported (e.g. a config file that shares the auth document's shape but no tokens).

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/e12d23b111a9d691. Report an issue: GitHub.