Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
/ github_auth Public archive

A django application to login via github.

License

Notifications You must be signed in to change notification settings

coogger/github_auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github Auth

A django application to login with github.

MIT License releases last-commit Codacy Badge style style style

🚀 Installation and Usage 🚀

Installation

  • Github Aauth can be installed by running pip install github_auth.

  • Add "github_auth" to your INSTALLED_APPS setting:

INSTALLED_APPS = []
    # …
    "github_auth",
]
  • Set login and logout redirect url
LOGIN_REDIRECT_URL = "/" # after users login, they will redirect this url
LOGOUT_REDIRECT_URL = "/" # after users logout
  • Set your Github app configuration
GITHUB_AUTH = dict(
    redirect_uri="your_redirect_uri",
    scope="your scope",
    client_secret="your github client_secret",
    client_id="your github client_id",
)

Usage

  • In your myapp/urls.py:
urlpatterns = [
    ...
    path("accounts/github/", include('github_auth.urls')),
]
  • In your myapp/templates:
<a href="{% url 'redirect-github' %}">login wia github</a>
  • Github Auth extend default user model using OneToOneField so you can use as below.

after login to show profile image from github profile image

<img src="request.user.github_auth.avatar_url" title="request.user">
<p>{{request.user.github_auth.get_extra_data_as_dict.bio}}</p>
request.user.github_auth.get_extra_data_as_dict.bio # and other extra_data fields
request.user.github_auth.avatar_url

or

from django.contrip.auth.models import User

admin_avatar_url = User.objects.get(username="admin").github_auth.avatar_url

and you can use next field to redirect any addresses for example; The user will be redirected to the same address after login.

<a href="{% url 'redirect-github' %}?next={{ request.META.PATH_INFO }}">login wia github</a>

Author / Social

👤 Hakan Çelik 👤

Version Notes

V0.0.7

  • Next attr added when login or logout
  • Get email bug fixed
  • Migrations files added

V0.0.5

  • View ( update githubuser ) bug fixed

V0.0.2

  • login
  • logout
  • get extra data