[PR #334] [CLOSED] fix(kiro): 修复 EU 区域账户的 API 访问问题 #337

Closed
opened 2026-02-27 07:19:00 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/334
Author: @yxc0915
Created: 2/23/2026
Status: Closed

Base: mainHead: fix-kiro-eu-region


📝 Commits (3)

  • 70e4df3 修复eu地区账户的api访问问题
  • b9b4868 fix(kiro): correct OIDC region inference and token refresh fallback
  • 860cb0b fix(kiro): enforce official endpoints and ignore custom KIRO URLs

📊 Changes

2 files changed (+119 additions, -20 deletions)

View changed files

📝 src/auth/kiro-oauth.js (+41 -8)
📝 src/providers/claude/claude-kiro.js (+78 -12)

📄 Description

问题描述

EU 区域(如 eu-central-1)的 Kiro 账户在进行 token 刷新和 API 调用时会失败,因为:

  1. idcRegion 未能正确推断,导致 SSO 刷新请求路由到错误的区域
  2. Q Service 端点未根据账户区域正确路由

修复内容

1. 新增 clientId 区域解析

  • 添加 \parseRegionFromClientId()\ 函数,从 base64url 编码的 clientId 中解析区域信息
  • 这是最可靠的区域来源,因为 clientId 由 Kiro 服务端生成

2. 改进区域推断逻辑

  • 优先使用 clientId 解析的区域
  • 当 idcRegion 与 clientId 区域不匹配时,以 clientId 区域为准
  • 确保 SSO 刷新请求路由到正确的区域端点

3. Q Service 端点区域路由

  • 添加 \getQServiceEndpoint()\ 函数
  • Kiro Q Service 只有两个区域节点:us-east-1 和 eu-central-1
  • 根据 clientId 区域自动路由到正确的端点

4. 强制使用官方端点

  • 忽略用户自定义的 \KIRO_*\ URL 配置
  • 避免手动配置导致跨区刷新失败或不一致行为

5. Token 刷新健壮性

  • 刷新时保留原 refreshToken(如果响应未返回新的)
  • 为 expiresIn 添加默认值处理

影响范围

  • \src/auth/kiro-oauth.js\
  • \src/providers/claude/claude-kiro.js\

测试

已在 两个不同的EU 区域账户上验证修复有效。


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/334 **Author:** [@yxc0915](https://github.com/yxc0915) **Created:** 2/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-kiro-eu-region` --- ### 📝 Commits (3) - [`70e4df3`](https://github.com/justlovemaki/AIClient-2-API/commit/70e4df397579d500165458ff246832c699ba7d5d) 修复eu地区账户的api访问问题 - [`b9b4868`](https://github.com/justlovemaki/AIClient-2-API/commit/b9b486848727fbdf971c562a0497afb0de3c04b3) fix(kiro): correct OIDC region inference and token refresh fallback - [`860cb0b`](https://github.com/justlovemaki/AIClient-2-API/commit/860cb0bcd9e1fb823e60e75da4987e0645693fea) fix(kiro): enforce official endpoints and ignore custom KIRO URLs ### 📊 Changes **2 files changed** (+119 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `src/auth/kiro-oauth.js` (+41 -8) 📝 `src/providers/claude/claude-kiro.js` (+78 -12) </details> ### 📄 Description ## 问题描述 EU 区域(如 eu-central-1)的 Kiro 账户在进行 token 刷新和 API 调用时会失败,因为: 1. idcRegion 未能正确推断,导致 SSO 刷新请求路由到错误的区域 2. Q Service 端点未根据账户区域正确路由 ## 修复内容 ### 1. 新增 clientId 区域解析 - 添加 \parseRegionFromClientId()\ 函数,从 base64url 编码的 clientId 中解析区域信息 - 这是最可靠的区域来源,因为 clientId 由 Kiro 服务端生成 ### 2. 改进区域推断逻辑 - 优先使用 clientId 解析的区域 - 当 idcRegion 与 clientId 区域不匹配时,以 clientId 区域为准 - 确保 SSO 刷新请求路由到正确的区域端点 ### 3. Q Service 端点区域路由 - 添加 \getQServiceEndpoint()\ 函数 - Kiro Q Service 只有两个区域节点:us-east-1 和 eu-central-1 - 根据 clientId 区域自动路由到正确的端点 ### 4. 强制使用官方端点 - 忽略用户自定义的 \KIRO_*\ URL 配置 - 避免手动配置导致跨区刷新失败或不一致行为 ### 5. Token 刷新健壮性 - 刷新时保留原 refreshToken(如果响应未返回新的) - 为 expiresIn 添加默认值处理 ## 影响范围 - \src/auth/kiro-oauth.js\ - \src/providers/claude/claude-kiro.js\ ## 测试 已在 两个不同的EU 区域账户上验证修复有效。 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:19:00 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#337
No description provided.