Authentication
The Authentication API is used for user signup, login, token refresh, and getting the currently logged-in user.
Backend folder:
app/auth/
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/signup | Create a new user account |
| POST | /auth/login | Login user and receive access token |
| POST | /auth/refresh | Refresh expired access token |
| GET | /auth/users/me | Get current logged-in user |
Signup
POST /auth/signup
Creates a new user account.
Request Body Example
{
"password": "password123",
"full_name": "Admin User"
}
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | User created successfully |
| 400 | Invalid request data |
| 409 | User already exists |
Login
POST /auth/login
Logs in a user and returns an authentication token.
Request Body Example
{
"password": "password123"
}
Response Example
{
"access_token": "jwt_token_here",
"token_type": "bearer"
}
Refresh Token
POST /auth/refresh
Creates a new access token using a refresh token.
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | Token refreshed successfully |
| 401 | Invalid or expired refresh token |
Get Current User
GET /auth/users/me
Returns information about the currently logged-in user.
Required Header
Authorization: Bearer YOUR_ACCESS_TOKEN
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | Current user returned successfully |
| 401 | User is not authenticated |