登录 POST
使用邮箱和密码登录,获取 JWT 令牌。
端点
POST https://api.pocketalert.app/v1/auth/signin请求
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Content-Type | ✅ | application/json |
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | ✅ | 你注册时使用的邮箱地址 |
password | string | ✅ | 你的账户密码 |
请求示例
bash
curl -X POST "https://api.pocketalert.app/v1/auth/signin" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your-password"
}'javascript
const response = await fetch('https://api.pocketalert.app/v1/auth/signin', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: '[email protected]',
password: 'your-password'
})
});
const { token } = await response.json();
// Use token in Authorization header for subsequent requestspython
import requests
response = requests.post(
'https://api.pocketalert.app/v1/auth/signin',
json={
'email': '[email protected]',
'password': 'your-password'
}
)
data = response.json()
# Use token in Authorization header for subsequent requestsphp
$response = Http::post('https://api.pocketalert.app/v1/auth/signin', [
'email' => '[email protected]',
'password' => 'your-password',
]);
$token = $response->json()['token'];
// Use token in Authorization header for subsequent requests响应
成功响应
200 OK
登录成功
| 字段 | 类型 | 说明 |
|---|---|---|
token | string | 用于 API 身份验证的 JWT 令牌 |
email | string | 用户的邮箱地址 |
name | string | 用户的显示名称 |
avatar | string | 用户头像图片的 URL |
json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"email": "[email protected]",
"name": "John Doe",
"avatar": ""
}使用令牌
获取令牌后,在后续请求中加入该令牌:
bash
curl -X GET "https://api.pocketalert.app/v1/messages" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."错误响应
| 状态码 | 说明 |
|---|---|
400 | 请求错误:缺少邮箱或密码,或验证码校验失败 |
401 | 凭据无效:密码错误或邮箱不存在 |
建议
对于服务端集成,我们建议使用 API 密钥 代替 JWT 令牌。API 密钥不会过期,也更易于管理。