This project implements user authentication using Django Rest Framework (DRF) and Simple JWT, with a custom login implementation.
✅ User Registration (Signup)
✅ User Login with JWT (Custom Implementation)
✅ Access & Refresh Token Mechanism
✅ Token Refresh Endpoint
✅ Secure API Authentication
-
Clone the repository
git clone https://github.com/yourusername/yourproject.git cd yourproject -
Create & activate virtual environment
python -m venv env source env/bin/activate # MacOS/Linux env\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Run migrations
python manage.py migrate
-
Run the development server
python manage.py runserver
Endpoint: POST /user/api/register/
Request Body:
{
"username": "testuser",
"email": "test@example.com",
"password": "yourpassword"
}Response:
{
"id": 1,
"username": "testuser",
"email": "test@example.com"
}Endpoint: POST /user/api/login/
Request Body:
{
"username": "testuser",
"password": "yourpassword"
}Response:
{
"refresh": "your_refresh_token",
"access": "your_access_token"
}Endpoint: POST /user/api/token/refresh/
Request Body:
{
"refresh": "your_refresh_token"
}Response:
{
"access": "your_new_access_token"
}Use the access token in the Authorization header:
Authorization: Bearer your_access_tokenCreate a .env file and add:
SECRET_KEY=your_secret_key
DEBUG=True
ALLOWED_HOSTS=*
Pull requests are welcome! Feel free to improve the authentication system or add new features. 🚀
This project is licensed under the MIT License.