Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

coogger/github_auth

Repository files navigation

Github Auth

A django application to login with github.

MIT Licensereleaseslast-commitCodacy Badgestylestylestyle

🚀 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 urlLOGOUT_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:
<ahref="{% 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

<imgsrc="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 fieldsrequest.user.github_auth.avatar_url

or

fromdjango.contrip.auth.modelsimportUseradmin_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.

<ahref="{% 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

Packages

No packages published

Contributors 2

  •  
  •  

Languages