modelstudioai / modelstudioai/cli

[bug] International site: console commands still report NotLogined after AK/SK auto-refresh (GenerateCLIAccessToken token rejected)

未關閉
#195 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
TypeScript
星號
333
分支
28
平均合併
1 天 9 小時
30 天內合併 PR
33

描述

Environment

  • bl 1.20.0, macOS
  • Alibaba Cloud international account, console gateway ap-southeast-1 / international
  • Profile: token-plan (base_url https://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.tsresolveRegion() 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

  1. International account, RAM user with AliyunBailianFullAccess, Permanent AccessKey.
  2. bl auth login --console (works), then bl auth login --open-api --access-key-id ... --access-key-secret ...
  3. bl usage token-plan --verbose → refresh 200, console still NotLogined.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。