2. Agenda
Introduction to django
Normal User Authentication with username, password
Creating google app
Login with Google
Custom User Authentication
Creating facebook app
4. How Django Works?
User will enter url
Web page in browser Request send to
django
urls.py
View mapped to the url will execute
Displays particular html
Display 404 page in the browserUser
Check all urls
Display html Page
Check In ModelsDatabase
If
ma
tch
6. Start Project
$ Download the code from https://github.com/nikhila05/social_logins
$ Place Compressed file in current folder
$ pip install -r requirements.txt
$ python manage.py migrate
$ python manage.py runserver
7. Rendering HTML Code
social_logins/urls.py
url(r'^home/', home_display),
social/views.py
from django.shortcuts import render
def home_display(request):
return render(hello.html')
templates/page.html
<h1>Hello world!! Welcome to Micropyramid</h1>
8. How Authentication Works In Django
Username
Password
Submit
Web page in browser Request send to
django in POST
Authenticates user
entered details
If
user
User will logged in Succssfully
Display user details as wrong
in the browser
User
10. How to create google app?
open https://console.developers.google.com/
Click on new project
Enter Your app name, contact email id.
Click on credentials tab in menu, create credentials.
Enter your application domain name, redirect url.
11. Google Login
Google login
Web page in browser Request send to
django as GET
Request will send to google api with app
details, permission details
If
ok?
google api will send code in GET
RequestUser
Graph api will authorize us
details
Request will send to google api
with app details, code to get
accesstoken
Using access token, well get user
details User Logged in Successfully
12. Custom User Authentication
User can logged into the site without entering password
Check user exists with username not with password
Overriding with normal authentication backend to
Login with only username
13. How to create facebook app?
open https://developers.facebook.com
Click on add a new app
Enter Your app name, contact email id.
Click on settings tab in menu, you will find app id, secret
values.
Click on add a product to add facebook login to your site.
14. Facebook Login
Facebook login
Web page in browser Request send to
django as GET
Request will send to graph api with app
details, permission details
If
ok?
Graph api will send code in GET
RequestUser
Graph api will authorize us
facebook details
Request will send to graph api with
app details, code to get
accesstoken
Using access token, well get user
details User Logged In Successfully