gitlink-cli/skills/gitlink-shared/examples/auth-workflow.md

58 lines
994 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 认证工作流
## 场景:首次使用 gitlink-cli
### 步骤 1登录
```bash
gitlink-cli auth login
# 交互式输入用户名和密码
# Token 自动存储到 OS Keychain
```
### 步骤 2验证登录
```bash
gitlink-cli auth status
# 输出:✓ Logged in as wbtiger
```
### 步骤 3测试 API 访问
```bash
gitlink-cli user +me
# 返回当前用户信息
```
## 场景Token 过期重新登录
```bash
# 遇到 401 错误时
gitlink-cli auth login
# 或使用已有 Token
gitlink-cli auth login --token
# 粘贴 Token 后回车
```
## 场景:切换账户
```bash
# 登出当前账户
gitlink-cli auth logout
# 登录新账户
gitlink-cli auth login
```
## 常见问题
**Q: Token 存储在哪里?**
A: OS KeychainmacOS/ Secret ServiceLinux/ Credential ManagerWindows
**Q: Token 有效期多长?**
A: 7 天,过期需重新登录
**Q: 如何使用已有 Token**
A: 运行 `gitlink-cli auth login --token`,粘贴 Token 后回车