decolua/9router · error · Error

`Device authorization failed: ${error}`

Error message

`Device authorization failed: ${error}`

What it means

Thrown by the Kiro OAuth provider at step 2 of device login: after client registration succeeded, the device-authorization request (POST including startUrl) returned non-2xx, so no deviceData (verification URI/user code) is available for polling. The upstream error body is embedded in the message.

Source

Thrown at src/lib/oauth/providers/kiro.js:57

    const clientInfo = await registerRes.json();

    // Step 2: Request device authorization
    const deviceRes = await fetch(deviceAuthUrl, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Accept: "application/json",
      },
      body: JSON.stringify({
        clientId: clientInfo.clientId,
        clientSecret: clientInfo.clientSecret,
        startUrl,
      }),
    });

    if (!deviceRes.ok) {
      const error = await deviceRes.text();
      throw new Error(`Device authorization failed: ${error}`);
    }

    const deviceData = await deviceRes.json();

    // Return combined data for polling
    return {
      device_code: deviceData.deviceCode,
      user_code: deviceData.userCode,
      verification_uri: deviceData.verificationUri,
      verification_uri_complete: deviceData.verificationUriComplete,
      expires_in: deviceData.expiresIn,
      interval: deviceData.interval || 5,
      // Store client credentials for token exchange
      _clientId: clientInfo.clientId,
      _clientSecret: clientInfo.clientSecret,
      _region: region,
      _authMethod: authMethod,
      _startUrl: startUrl,

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Inspect the embedded error body in the message for the upstream reason.
  2. Verify the startUrl value passed to device authorization is current and valid.
  3. Re-run the full flow so a fresh client registration precedes device authorization (avoid reusing cached clientInfo).
  4. Retry after a delay if the status indicates a transient 5xx.
Defensive patterns

Strategy: retry

Try / catch

try {
  await kiroProvider.login(config);
} catch (e) {
  if (e.message.startsWith('Device authorization failed:')) {
    // read embedded body; restart full flow (fresh registration) on client errors, backoff-retry on 5xx
  } else throw e;
}

Prevention

When it happens

Trigger: The device authorization endpoint responds 4xx/5xx: registered client rejected, invalid startUrl, expired registration from step 1, device-auth service outage, or request blocked by network/proxy.

Common situations: Kiro service incident; stale startUrl configuration; account/region mismatch between the registered client and the startUrl; firewall blocking the device-auth endpoint.

Related errors


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