鉴权 API
基址:https://notenow.cn/note(下文用 $BASE)。
| 方法 | 路径 | 说明 |
|---|---|---|
POST |
/api/auth/register |
注册 |
POST |
/api/auth/register-with-email |
邮箱注册 |
POST |
/api/auth/send-code |
发送验证码 |
POST |
/api/auth/login/password |
密码登录 |
POST |
/api/auth/login/code |
验证码登录 |
POST |
/api/auth/logout |
登出 |
POST |
/api/auth/reset-password |
重置密码 |
POST |
/api/auth/change-password |
修改密码 |
GET |
/api/auth/me |
当前用户 |
PATCH |
/api/auth/profile |
更新资料 |
POST |
/api/auth/avatar |
上传头像 |
POST /api/auth/login/passwordContent-Type: application/json{ "identifier": "you@example.com", "password": "your-password"}{ "success": true, "token": "eyJhbGciOi...", "user": { "id": "...", "display_name": "..." }}export BASE=https://notenow.cn/note
curl -sS "$BASE/api/auth/login/password" \ -H 'Content-Type: application/json' \ -d '{ "identifier": "you@example.com", "password": "your-password" }'TOKEN=$(curl -sS "$BASE/api/auth/login/password" \ -H 'Content-Type: application/json' \ -d '{"identifier":"you@example.com","password":"your-password"}' \ | python3 -c 'import sys,json; print(json.load(sys.stdin)["token"])')
echo "$TOKEN"curl -sS "$BASE/api/auth/register" \ -H 'Content-Type: application/json' \ -d '{ "identifier": "you@example.com", "password": "your-password", "display_name": "NoteNow Dev" }'display_name 可选。
当前用户 / 登出
Section titled “当前用户 / 登出”# 我是谁curl -sS "$BASE/api/auth/me" \ -H "Authorization: $TOKEN"
# 登出curl -sS "$BASE/api/auth/logout" \ -H "Authorization: $TOKEN" \ -X POSTcurl -sS "$BASE/api/auth/profile" \ -X PATCH \ -H "Authorization: $TOKEN" \ -H 'Content-Type: application/json' \ -d '{"display_name":"新昵称"}'