GithubHelp home page GithubHelp logo

django-rest-auth's Introduction

Django REST API Authentication System

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.

Prerequisites

  • Python 3.7 or above
  • Django 3.0 or above
  • Django REST Framework 3.11 or above

Installation

  1. Clone the repository:
git clone 
  1. Navigate to the project directory:
cd project
  1. Install the dependencies:
pip install -r requirements.txt
  1. Set up the database:
python manage.py migrate
  1. Start the development server:
python manage.py runserver

API Endpoints

Registration

  • 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]"
}

Login

  • POST /api/token/

Authenticates a user and generates an authentication token.

Request Body:

{
  "username": "your-username",
  "password": "your-password"
}

Response:

{
  "token": "your-authentication-token"
}

User Profile

  • 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]"
}

Error Handling

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.

Conclusion

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.

django-rest-auth's People

Contributors

sarthak7509 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.