Skip to content

ymoondhra/django-token-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-token-base

Demonstration: https://drive.google.com/drive/u/0/folders/1IOAupRokQvc6zpEiNif99iOT2pcD7Vnl
This is a Django project that serves as a base model to build Django back-end APIs that require token and social media authentication. It utilizes Django Rest Framework and django-rest-auth.
The compatible front-end application can be found here.

Table of Contents

Prerequisites

To thoroughly comprehend this solution, it is highly recommended to have a strong understanding of the following:

Project Description

This project covers the essential authentication functionalities of a back-end API that uses token authentication, which can be found here, and will eventually support social media authentication. The CustomUser is set as the authentication user model, which builds off of Django's usual user model, to allow developers to add extra user data (e.g. user's occupation or country of residence).

Run The Project

  1. mkdir token_auth
  2. cd token_auth
  3. python3 -m venv env
  4. source env/bin/activate
  5. pip install --upgrade pip
  6. pip3 install django && pip3 install djangorestframework && pip3 install django-rest-auth && pip3 install django-allauth
  7. git clone https://github.com/ymoondhra/django-token-base
  8. cd django-token-base
  9. python3 manage.py runserver
  10. python3 manage.py makemigrations && python3 manage.py migrate
  11. Navigate to http://localhost:8000/api/v1/rest-auth/login/

Versions

Existing Versions
# Functionality Additions Compatible with Front-End Version #
1 Support for endpoints found below with test cases 1
Future Versions
# Functionality Additions Compatible with Front-End Version #
2 Use email address as username -
3 Support social media account authentication and creation -

Why I Built This

In my experiences with full-stack applications, I have noticed how I have to rebuild the same functionalities every time (e.g. authentication), often having to look back at previous projects I have created. I want to minimize the amount of time developers spend on the repetitive aspects of creating a back-end API for full-stack applications.

Moreover, I want developers to be able to pull different versions (a.k.a. releases) of this project for the different functionalities they need. For example, If someone wants to build a back-end API that allows users to log in with Facebook or log in with their actual username, a developer may pull down only Version 3.0.0, which is the first version that has the Facebook login feature. However, Version 3.0.0 uses email to login/logout instead of username. Therefore, the best approach would be to pull down the directories of Version 1.0.0 (which uses username) and Version 3.0.0, compare the code, and use the helpful comments within the code to decide what code to remove.

For the developers who would prefer to start from scratch but use this project for reference, the section below outlines how I went about coding this API.
All versions can be found here.

How I Built This

Version 1

Overall Coding Structure
      1. Build Users app
      2. Build Api app

Individual App Coding Structure
      1. Start app with command line
      2. Build models
      3. Build serializers
      4. Build views
      5. Attach to URLs
      6. Update settings.py as needed
      7. Migrate
      8. Configure admin: create superuser in command prompt and Add Site in admin website

Project Deployment
      (OPTIONAL). Hide secret key
      1. Create requirements.txt using pip freeze
      2. Push token_auth and README.md to GitHub (not env folder)

API Endpoints

All of these API endpoints are supported except the social media endpoints

About

Django REST API for token authentication using Django REST Framework and django-rest-auth. Demonstration can be found here:

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages