Skip to content

A User authentication APIs built using Django & DRF in Python.

License

Notifications You must be signed in to change notification settings

anuraagnagar/django-authentication-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Authentication API

User Authentication APIs using Django Rest Framework (DRF). It provides a flexible and secure users authentication endpoints for your Django applications.

Table of Contents

  1. Features
  2. Prerequisites
  3. Sample API Request
  4. API Endpoints
  5. Installation
  6. License

Features

  • Token-based authentication with Http-Cookies.
  • Username or Email authentication.
  • User registration and profile management.
  • User login and logout functionality.
  • User recover password with their email address.
  • User reset email address to their new email.

Prerequisites

Sample API Request

User Registration API

POST /api/user/register/
Content-Type: application/json

{
  "username": "john_doe",
  "email": "[email protected]",
  "password": "John@1980"
}

User Login API

POST /api/user/login/
Content-Type: application/json

{
  "username": "username_or_email",
  "password": "your_password"
}

API Endpoints

API Endpoints User
Anonymous User Authenticated User
api/user/register/ POST -
api/user/login/ POST -
api/user/logout/ - GET
api/user/account/confirm/token/ POST -
api/user/account/reset-password/ POST POST
api/user/account/reset-password/confirm/token/ UPDATE UPDATE
api/user/account/email/reset/ - POST
api/user/account/email/confirm/token/ - UPDATE
api/user/account/password/change/ - UPDATE
api/user/account/profile - GET, UPDATE

Installation

1. Clone the repository

git clone https://github.com/anuraagnagar/django-authentication-API.git

2. Change the directory.

cd django-authentication-API

3. Create a virtual environment.

python -m venv venv
To activate:
source venv/bin/activate  # On MacOS/Linux
venv\Scripts\activate  # On Windows

4. Install requirement dependencies.

pip install -r requirements.txt

Before running migrations and starting the development server, make sure to duplicate the .env.example file as .env in your project's root directory, and then fill all the necessary details for all the environment variables within the .env file."

5. Run migrations.

python manage.py migrate

6. Start the development server.

python manage.py runserver

Visit http://localhost:8000/ in your browser for access this application.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Anurag Nagar