跳转到内容

鉴权 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/password
Content-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"
}'
终端窗口
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 可选。

终端窗口
# 我是谁
curl -sS "$BASE/api/auth/me" \
-H "Authorization: $TOKEN"
# 登出
curl -sS "$BASE/api/auth/logout" \
-H "Authorization: $TOKEN" \
-X POST
终端窗口
curl -sS "$BASE/api/auth/profile" \
-X PATCH \
-H "Authorization: $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"display_name":"新昵称"}'