AtriSaxena / DjangoAPI-Starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIMPLE STARTER API WITH USER AUTHENTICATION

Django REST framework is a powerful and flexible toolkit for building Web APIs.

Requirements

  • Python 3.6
  • Django (2.1)
  • Django REST Framework
  • Django Rest Auth

Installation

	pip install django
	pip install djangorestframework
	pip install django-rest-auth
	pip install django-allauth

Login and Tokens

To get a token first we have to login

	http http://127.0.0.1:8000/rest-auth/login/ username="admin" password="root1234"

after that, we get the token

{
    "key": "2d500db1e51153318e300860064e52c061e72016"
}

ALL request must be authenticated with a valid token, otherwise they will be invalid

We can create new users. (password1 and password2 must be equal)

http POST http://127.0.0.1:8000/rest-auth/registration/ username="USERNAME" password1="PASSWORD" password2="PASSWORD"

And we can logout, the token must be your actual token

http POST http://127.0.0.1:8000/rest-auth/logout/ "Authorization: Token <YOUR_TOKEN>" 

Uses

Start the Server

Python manage.py runserver

About

License:MIT License


Languages

Language:Python 100.0%