로그인 및 토큰 API
개요
로그인 및 토큰 API는 사용자 인증과 토큰 관리 기능을 제공합니다.
주요기능
- 로그인: 이메일과 비밀번호로 로그인
- 토큰 갱신: 리프레시 토큰으로 액세스 토큰 갱신
[POST] /auth/login - 로그인
로그인
사용자 이메일과 비밀번호로 로그인합니다.
- HTTP Method:
POST - 인증: 불필요
Headers
| Header | Type | Description | Required |
|---|---|---|---|
| Content-Type | application/json | 요청 본문 타입 | ✔ |
Request Body
| 필드 | 타입 | 설명 | Required |
|---|---|---|---|
| string | 사용자 이메일 주소 | ✔ | |
| password | string | 사용자 비밀번호 | ✔ |
Request Body Example
{
"email": "user@example.com",
"password": "password"
}
Responses
| Http Status Code | 설명 | Error Code(s) |
|---|---|---|
200 OK | 로그인 성공 | - |
401 Unauthorized | 인증 실패 | - |
200 OK - 성공
{
"account": {
"id": 1,
"email": "user@example.com",
"name": "John Doe"
},
"tokens": {
"access": "access_token",
"refresh": "refresh_token"
}
}
| 필드 | 타입 | 설명 |
|---|---|---|
| account | object | 회원 정보 |
| account.id | number | 사용자 ID |
| account.email | string | 사용자 이메일 |
| account.name | string | 사용자 이름 |
| tokens | object | 토큰 정보 |
| tokens.access | string | 액세스 토큰 |
| tokens.refresh | string | 리프레시 토큰 |
401 Unauthorized - 인증 실패
예시: 이메일 또는 비밀번호가 잘못된 경우
{
"status": 401,
"code": 40100,
"message": "Unauthorized",
"detail": ""
}
[POST] /auth/token/refresh - 토큰 갱신
토큰 갱신
리프레시 토큰으로 새로운 액세스 토큰과 리프레시 토큰을 발급받습니다.
- HTTP Method:
POST - 인증: 불필요
Headers
| Header | Type | Description | Required |
|---|---|---|---|
| Content-Type | application/json | 요청 본문 타입 | ✔ |
Request Body
| 필드 | 타입 | 설명 | Required |
|---|---|---|---|
| token | string | 리프레시 토큰 | ✔ |
Request Body Example
{
"token": "refresh_token"
}
Responses
| Http Status Code | 설명 | Error Code(s) |
|---|---|---|
200 OK | 토큰 갱신 성공 | - |
401 Unauthorized | 유효하지 않은 토큰 | - |
200 OK - 성공
{
"access": "new_access_token",
"refresh": "new_refresh_token"
}
| 필드 | 타입 | 설명 |
|---|---|---|
| access | string | 새로운 액세스 토큰 |
| refresh | string | 새로운 리프레시 토큰 |
401 Unauthorized - 인증 실패
예시: 유효하지 않은 리프레시 토큰
{
"status": 401,
"code": 40100,
"message": "Invalid refresh token",
"detail": ""
}