This Django REST API is designed to provide a secure and reliable authentication system for your web applications. It allows users to register, log in, and perform authenticated actions using token-based authentication.
- Python 3.7 or above
- Django 3.0 or above
- Django REST Framework 3.11 or above
- Clone the repository:
git clone
- Navigate to the project directory:
cd project
- Install the dependencies:
pip install -r requirements.txt
- Set up the database:
python manage.py migrate
- Start the development server:
python manage.py runserver
POST /api/create/
Registers a new user with the provided username, email, and password.
Request Body:
{
"username": "your-username",
"email": "[email protected]",
"password": "your-password"
}
Response:
{
"id": 1,
"username": "your-username",
"email": "[email protected]"
}
POST /api/token/
Authenticates a user and generates an authentication token.
Request Body:
{
"username": "your-username",
"password": "your-password"
}
Response:
{
"token": "your-authentication-token"
}
GET /api/me/
Retrieves the authenticated user's profile information.
Note:
Authentication toke is needed on header inorder to recive data
Authorization: Token your-authentication-token
Response:
{
"id": 1,
"username": "your-username",
"email": "[email protected]"
}
The API follows RESTful principles and returns appropriate status codes and error messages for invalid requests. Here are some common error responses:
- 400 Bad Request: Invalid request data.
- 401 Unauthorized: Missing or invalid authentication token.
- 404 Not Found: Resource not found.
- 500 Internal Server Error: Unexpected server error.
With this Django REST API authentication system, you can easily integrate user registration, login, and secure authenticated actions into your web applications. Feel free to customize and extend the API to fit your specific requirements.