Skip to content

mabdullahadeel/django-rest-github-oauth

Repository files navigation

django-rest-github-oauth

Documentation Status Updates

A simple python library to authenticate users with github in Django applications.

Requirements

  • Python (3.7, 3.8, 3.9)
  • Django (2.x, 3.x, 4.x)
  • Django REST Framework (3.10, 3.11, 3.12)

Setup

Install the package in your python environment using pip.

pip install django-rest-github-oauth

For detailed information regarding the installation, see the :ref:`installation guide <target to installation>`.

Then your django project must be configured to use the library. For that include it in INSTALLED_APPS of your settings.py. Besides that, you will have to include the auth handler app in installed apps.

Currently, django-rest-github-oauth supports the following authentication backends:

Using JWT

INSTALLED_APPS = [ # ... 'rest_framework_simplejwt', 'django_rest_github_oauth', # ... ]

Using Token Authentication

INSTALLED_APPS = [ # ... 'rest_framework.authtoken', 'django_rest_github_oauth', # ... ]

Then add the following to your settings.py:

GITHUB_AUTH_KEY = "<your_github_app_key>" GITHUB_AUTH_SECRET = "<your_github_app_secret>" GITHUB_AUTH_USE_JWT = True # False if you're using token based authentication GITHUB_AUTH_CALLBACK_URL = "http://localhost:3000/auth/success/" # url of the frontend handling redirects from github GITHUB_AUTH_ALLOWED_REDIRECT_URIS = [ GITHUB_AUTH_CALLBACK_URL ]

Note

If you have not yet created an app on github, you need to create an app to get the client id and secret. register app with github.

Warning

You need to set the GITHUB_AUTH_CALLBACK_URL you set on github while creating the app.

About

A simple python library to authenticate users with github in Django applications.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published