modelstudioai / modelstudioai/cli
[bug] International site: console commands still report NotLogined after AK/SK auto-refresh (GenerateCLIAccessToken token rejected)
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 333
- 派生
- 28
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 33
描述
Environment
bl1.20.0, macOS- Alibaba Cloud international account, console gateway
ap-southeast-1/international - Profile:
token-plan(base_urlhttps://token-plan.ap-southeast-1.maas.aliyuncs.com) - Credentials: RAM user (Permanent AccessKey only) with
AliyunBailianFullAccess
Expected (per #95)
After bl auth login --open-api, a console command that hits NotLogined silently refreshes the access token from AK/SK and retries successfully.
Actual
The refresh runs and GenerateCLIAccessToken returns 200 with a cliAccessToken, but the retried console call still fails with Console session is not logged in or has expired. (exit 3). Every console command is affected (usage token-plan, usage free, workspace list).
Two separate problems observed:
1. Region resolution falls back to cn for non-DashScope base URLs
packages/core/src/auth/refresh-token.ts → resolveRegion() only matches the three REGIONS DashScope URLs. A token-plan profile (*.ap-southeast-1.maas.aliyuncs.com) doesn't match, so the refresh goes to modelstudio.cn-beijing.aliyuncs.com for an international account.
> POST https://bailian-singapore-cs.alibabacloud.com/cli/api.json?action=IntlBroadScopeAspnGateway&...
< 200
Refreshing access token...
> POST https://modelstudio.cn-beijing.aliyuncs.com/modelstudio/cli/generateAccessToken
< 200 OK
> POST https://bailian-singapore-cs.alibabacloud.com/cli/api.json?...
< 200
Error: Console session is not logged in or has expired.
2. Even with the correct intl host, the token is rejected
To rule out (1) I created a profile with base_url=https://dashscope-intl.aliyuncs.com, console_site=international, console_region=ap-southeast-1, then bl auth login --open-api. The refresh now hits modelstudio.ap-southeast-1.aliyuncs.com and gets a token, but the intl console gateway still answers NotLogined for all console commands.
So on the international site the token produced by GenerateCLIAccessToken does not appear to be accepted by IntlBroadScopeAspnGateway (at least for a RAM user). Is there a required RAM permission / workspace membership / site setting for this to work, or is intl not supported yet?
Side effect worth noting
bl auth login --open-api and every failed auto-refresh overwrite access_token in config.json, which replaces a still-valid browser-login console session with an unusable token. A guard (only overwrite when the new token actually passes a console call) would avoid that.
Repro
- International account, RAM user with
AliyunBailianFullAccess, Permanent AccessKey. bl auth login --console(works), thenbl auth login --open-api --access-key-id ... --access-key-secret ...bl usage token-plan --verbose→ refresh 200, console still NotLogined.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 packages/core/src/auth/refresh-token.ts 开始,尤其关注 resolveRegion() 和 REGIONS 映射,然后使用 issue 中列出的配置文件和命令复现国际流程。比较生成 token 的 host 和控制台响应,并检查 config.json 中的 access_token 是如何被覆盖的。当国际行为已得到理解,并且报告的 refresh、拒绝和会话覆盖情况都有明确的测试或已记录的限制时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- authentication, cli
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100