Giter VIP home page Giter VIP logo

django-backend-with-oauth's Introduction

Django Backend with OAuth

This is a Django backend with OAuth authentication. It uses the Django Rest Framework to create a REST API. The OAuth authentication is done using the dj-rest-auth package.

This template is designed for applications using a SPA (Single Page Application) frontend. The frontend is expected to handle the OAuth flow and send the access token to the backend. The backend will then use the access token to authenticate the user.

Features

  • User creation/login/logout/reset password
  • Creating client applications for OAuth
  • OAuth authentication

Setup

  1. Clone the repository
  2. Create a virtual environment
python3 -m venv venv
source venv/bin/activate

or on Windows:

python -m venv venv
venv\Scripts\activate
  1. Install the dependencies
pip install -r requirements.txt
  1. Run the migrations
python manage.py migrate
  1. Create a superuser
python manage.py createsuperuser
  1. Run the server
python manage.py runserver

Additionally, there is a docker-compose file that can be used to run the backend, the PostgreSQL database, and a Redis server for caching. To use it, run:

docker-compose up

Usage

The API endpoints are available at http://localhost:8000/api/v1/. The admin panel is available at http://localhost:8000/admin/, and the dj-rest-auth endpoints are available at http://localhost:8000/auth/.

To create a new client application for OAuth, go to the admin panel and create a new Application. The Client id and Client secret will be generated automatically.

To authenticate a user, send a POST request to http://localhost:8000/auth/login/ with the following JSON body:

{
    "email": "your_email",
    "password": "your_password"
}

This will return an access token that can be used to authenticate future requests. Send the access token in the Authorization header with the value

Bearer your_access_token

License

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

Bugs, Security Vulnerabilities, and Contributing

If you find a bug or security vulnerability, please don't hesitate to create an issue or a pull request. Any contributions are welcome!

Built by

This project was built by Brandon Kong.

django-backend-with-oauth's People

Contributors

brandon-kong avatar

Stargazers

 avatar

Watchers

 avatar

django-backend-with-oauth's Issues

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.