{"record":{"id":"84d311401ecf0cfb","repo":"decolua/9router","slug":"device-authorization-failed-error","errorCode":null,"errorMessage":"`Device authorization failed: ${error}`","messagePattern":"`Device authorization failed: (.+?)`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/oauth/providers/kiro.js","lineNumber":57,"sourceCode":"    const clientInfo = await registerRes.json();\n\n    // Step 2: Request device authorization\n    const deviceRes = await fetch(deviceAuthUrl, {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Accept: \"application/json\",\n      },\n      body: JSON.stringify({\n        clientId: clientInfo.clientId,\n        clientSecret: clientInfo.clientSecret,\n        startUrl,\n      }),\n    });\n\n    if (!deviceRes.ok) {\n      const error = await deviceRes.text();\n      throw new Error(`Device authorization failed: ${error}`);\n    }\n\n    const deviceData = await deviceRes.json();\n\n    // Return combined data for polling\n    return {\n      device_code: deviceData.deviceCode,\n      user_code: deviceData.userCode,\n      verification_uri: deviceData.verificationUri,\n      verification_uri_complete: deviceData.verificationUriComplete,\n      expires_in: deviceData.expiresIn,\n      interval: deviceData.interval || 5,\n      // Store client credentials for token exchange\n      _clientId: clientInfo.clientId,\n      _clientSecret: clientInfo.clientSecret,\n      _region: region,\n      _authMethod: authMethod,\n      _startUrl: startUrl,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/src/lib/oauth/providers/kiro.js#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"Kiro service incident; stale startUrl configuration; account/region mismatch between the registered client and the startUrl; firewall blocking the device-auth endpoint.","solutions":["Inspect the embedded error body in the message for the upstream reason.","Verify the startUrl value passed to device authorization is current and valid.","Re-run the full flow so a fresh client registration precedes device authorization (avoid reusing cached clientInfo).","Retry after a delay if the status indicates a transient 5xx."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await kiroProvider.login(config);\n} catch (e) {\n  if (e.message.startsWith('Device authorization failed:')) {\n    // read embedded body; restart full flow (fresh registration) on client errors, backoff-retry on 5xx\n  } else throw e;\n}","preventionTips":["Re-register the client immediately before device authorization so registration can't be stale.","Validate startUrl is current and matches the registered client's region.","Retry with backoff on 5xx; restart the whole flow on 4xx."],"tags":["oauth","device-code-flow","http-4xx","network"],"backgroundTag":"device-code-flow-failed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}