Permalink
Browse files

Github oauth login

  • Loading branch information...
lukaszkuczynski committed Jun 21, 2017
1 parent 87c08b1 commit c1a82a74f787a280fe30d92056da57de1eede007
@@ -6,7 +6,7 @@
</head>
<body>
<a href="{% url "social:begin" "google-oauth2" %}">Google+</a>
<a href="{% url "social:begin" "github" %}">GITHUB login</a>
hello Mr {{user}}
</body>
@@ -29,7 +29,7 @@
<div class="wrapper style2">
<article id="work">
<header>
<h2>Stwórz podsumowanie</h2>
<h2>Stwórz podsumowanie, {{user}}</h2>
<!-- <p></p> -->
</header>
<div class="container">
View
@@ -20,5 +20,5 @@
urlpatterns = [
url(r'^$', views.index),
url(r'^create', views.create_summary),
url(r'^account', views.account),
url(r'^login', views.account),
]
@@ -7,7 +7,7 @@ def index(request):
@login_required()
def create_summary(request):
return render(request, 'app_160/create_summary.html')
return render(request, 'app_160/create_summary.html', context={"user": request.user})
def account(request):
current_user = request.user
@@ -64,6 +64,9 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends', # <--
'social_django.context_processors.login_redirect', # <--
],
},
},
@@ -122,13 +125,14 @@
STATIC_URL = '/static/'
AUTHENTICATION_BACKENDS = (
'social_core.backends.google.GoogleOAuth2',
'social_core.backends.github.GithubOAuth2',
)
SOCIAL_AUTH_URL_NAMESPACE = 'social'
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = os.getenv('SOCIAL_AUTH_GOOGLE_OAUTH2_KEY', 'provide_googleapi_key')
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = os.getenv('SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET', 'provide_googleapi_secret')
LOGIN_REDIRECT_URL = '/account'
SOCIAL_AUTH_GITHUB_KEY=os.getenv("GITHUB_CLIENT_ID","your_client_id_from_github")
SOCIAL_AUTH_GITHUB_SECRET =os.getenv("GITHUB_CLIENT_SECRET","your_client_secret_from_github")
LOGIN_REDIRECT_URL = '/'
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
@@ -16,10 +16,13 @@
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
from django.contrib import admin
from django.contrib.auth import views as auth_views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('app_160.urls')),
url('', include('social_django.urls', namespace='social')),
url(r'^login/$', auth_views.login, name='login'),
url(r'^logout/$', auth_views.logout, name='logout'),
url(r'^oauth/', include('social_django.urls', namespace='social')), # <--
]
@@ -1,2 +1,3 @@
set DJANGO_SECRET_KEY=write_key_here
python manage.py runserver

0 comments on commit c1a82a7

Please sign in to comment.