使用手冊Slima MCP › 進階:Debug OAuth 流程

進階:Debug OAuth 流程

最後更新 2026 年 5 月 25 日 · 閱讀約 5 分鐘

Web OAuth client 連不上 + 沒看到 reauth 跳出 → 多半是某一步靜默失敗。這篇教你怎麼一步步追蹤定位。

Slima Authorized Apps:OAuth 流程成功後 client 會出現在此頁

OAuth 9 步全流程

1. Client → POST /register (DCR — Dynamic Client Registration)
   ← 200 + client_id

2. Client → GET /.well-known/oauth-authorization-server
   ← 200 + OAuth metadata

3. Client → 開啟 /authorize?client_id=...&code_challenge=...
   ← Slima 顯示登入頁 / 授權頁

4. User → 點「授權」
   ← Slima 跳轉到 client 設的 redirect_uri + code=xxx

5. Client → POST /token (with code + code_verifier)
   ← 200 + access_token + refresh_token

6. Client → GET /mcp (Authorization: Bearer access_token)
   ← 200 + MCP capabilities

7-9. 後續每次 tool call:
     Client → POST /mcp/tools/call (+ Authorization)
     ← 200 + result

Self-host:wrangler tail

如果你 self-host

wrangler tail my-slima-mcp

即時看 worker logs、能看到每一步哪邊失敗。

用官方 server:回報問題

如果你用的是 Slima 官方 server,卻連不上:

  1. 看 client 的 logs(Claude Desktop / Cursor / ChatGPT),找出最後一個成功的步驟、以及失敗的那一步
  2. 截圖,再從 回報問題聯絡客服 回報
  3. 附上:你用哪個 client、版本號、撞到的 error code

用 curl 手動測

測 DCR

curl -X POST https://mcp.slima.ai/register \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "test",
    "redirect_uris": ["http://localhost:8901/callback"]
  }'

預期 200 + { client_id: "...", ... }

測 well-known

curl https://mcp.slima.ai/.well-known/oauth-authorization-server

預期 OAuth metadata JSON

用 access token call /mcp

curl https://mcp.slima.ai/mcp \
  -H "Authorization: Bearer your_access_token"

預期 200 + MCP capabilities

常見失敗點

步驟 失敗 處理
1 (DCR) 400 invalid_redirect_uri 確認 client 設的 redirect_uri 是 https 或 http://localhost
2 (well-known) 404 server URL 錯了
3 (authorize) 跳轉沒進 Slima 網路 / DNS / proxy 問題
4 (callback) redirect_uri mismatch DCR 註冊的 redirect_uri 跟 callback 不一致
5 (token exchange) invalid_grant code 過期(30 秒),重來
6 (mcp) 401 token 沒帶 Authorization header

相關

這篇有幫助嗎?