欢迎使用齐鲁工业大学图书馆预约系统 API。该 API 允许您使用学号和密码直接获取授权 Token。
登录 API 的端点为:
使用 POST 方法发送请求。
请确保包含以下请求头:
Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
请求体应为 JSON 格式,包含以下字段:
{
"username": "你的学号",
"password": "你的密码"
}
成功响应示例:
{
"success": true,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"user_info": {
"id": "2022xxxxxx",
"name": "张三",
"card": "2022xxxxxx",
"roleName": "学生",
"deptName": "计算机学院"
}
}
失败响应示例:
{
"success": false,
"message": "登录失败,未获取到有效认证信息"
}
获取到的 token 可以在后续请求中用于身份验证,通常放在 HTTP 请求头的 Authorization 字段中:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
fetch("", {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
},
body: JSON.stringify({
username: "你的学号",
password: "你的密码"
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log("登录成功,Token:", data.token);
console.log("用户信息:", data.user_info);
} else {
console.error("登录失败:", data.message);
}
})
.catch(error => console.error("请求出错:", error));