faresemad / Authentication-API

Build an Authentication API with Django.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication-API

Account: LinkedIn Account: Facebook Account: Twitter Account: Instagram Account: GitHub

Welcome to the Authentication API project. This project is a simple API that allows users to register, login, logout, change password, reset password, change email, and verify email. The API is built with Django and Django Rest Framework.

The API is built with the following technologies:

  • Django
  • Django Rest Framework
  • Djoser
  • Social_django

The API is built with the following features:

  • User Registration
  • User Login
  • User Logout
  • User Account Activation
  • User Password Change
  • User Password Reset
  • User Email Change
  • User Email Change Verification

Running the project

To run the project, follow the instructions below:

  1. Clone the repository
git clone https://github.com/faresemad/Authentication-API.git
  1. Change into the project directory
cd Authentication-API
  1. Create a virtual environment
python3 -m venv venv
  1. Activate the virtual environment
source venv/bin/activate
  1. Install the project dependencies
pip install -r requirements/local.txt
  1. Build the project
make build
  1. Run the project
make up
  1. Access the project on your browser
http://localhost:8000

API Endpoints

you can access the API endpoints on your browser by visiting the following URL:

http://localhost:8000/api/docs/

Social Endpoints

you can access the social endpoints on your browser by visiting the following URL:

  • Google: http://localhost:8000/api/auth/o/google-oauth2/?redirect_uri=http://localhost:8000/api/social-auth/complete/google-oauth2/

    • Notes:
      • You need to set redirect URI in the Google Developer Console to http://localhost:8000/api/social-auth/complete/google-oauth2/
      • You need to set the following environment variables in the .env (this file must be in .envs/ directory) file:
        • SOCIAL_AUTH_GOOGLE_OAUTH2_KEY
        • SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET
      • You need to set the following Settings in Djoser Settings:
            DJOSER = {
                # ...
                "LOGIN_FIELD": "email",
                "SOCIAL_AUTH_TOKEN_STRATEGY": "djoser.social.token.jwt.TokenStrategy",
                "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": [
                    "http://localhost:8000/api/social-auth/complete/google-oauth2/",
                ],
                # ...
            }
  • Twitter: http://localhost:8000/api/auth/o/twitter/?redirect_uri=http://localhost:8000/api/social-auth/complete/twitter/

    • Notes:
      • You need to set redirect URI in the Twitter Developer Portal to http://localhost:8000/api/social-auth/complete/twitter/
      • You need to set the following environment variables in the .env (this file must be in .envs/ directory) file:
        • SOCIAL_AUTH_TWITTER_KEY
        • SOCIAL_AUTH_TWITTER_SECRET
      • You need to set the following Settings in Djoser Settings:
            DJOSER = {
                # ...
                "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": [
                    # ...
                    "http://localhost:8000/api/social-auth/complete/twitter/",
                ],
                # ...
            }
  • GitHub: http://localhost:8000/api/auth/o/github/?redirect_uri=http://localhost:8000/api/social-auth/complete/github/

    • Notes:
      • You need to set redirect URI in the GitHub Developer Portal to http://localhost:8000/api/social-auth/complete/github/
      • You need to set the following environment variables in the .env (this file must be in .envs/ directory) file:
        • SOCIAL_AUTH_GITHUB_KEY
        • SOCIAL_AUTH_GITHUB_SECRET
      • You need to set the following Settings in Djoser Settings:
            DJOSER = {
                # ...
                "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": [
                    # ...
                    "http://localhost:8000/api/social-auth/complete/github/",
                ],
                # ...
            }
  • LinkedIn: http://localhost:8000/api/auth/o/linkedin-oauth2/?redirect_uri=http://localhost:8000/api/social-auth/complete/linkedin-oauth2/

    • Notes:
      • You need to set redirect URI in the LinkedIn Developer Portal to http://localhost:8000/api/social-auth/complete/linkedin-oauth2/
      • You need to set the following environment variables in the .env (this file must be in .envs/ directory) file:
        • SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY
        • SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET
      • You need to set the following Settings in Djoser Settings:
            DJOSER = {
                # ...
                "SOCIAL_AUTH_ALLOWED_REDIRECT_URIS": [
                    # ...
                    "http://localhost:8000/api/social-auth/complete/linkedin-oauth2/",
                ],
                # ...
            }

About

Build an Authentication API with Django.

License:MIT License


Languages

Language:Python 76.7%Language:Shell 13.2%Language:Dockerfile 5.8%Language:Makefile 4.3%