際際滷

際際滷Share a Scribd company logo
Social Login integration
hello Hands On Session
20th May, 2017
Hyderabad
Sponsored By
Agenda
Introduction to django
Normal User Authentication with username, password
Creating google app
Login with Google
Custom User Authentication
Creating facebook app
Django Architecture
Browser(Request/Response)
URLS
Views
Templates
Models
Database
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
Django Installation
$ sudo apt-get install python-setuptools python-dev build-essential
tree
$ sudo apt-get install python-pip python-virtualenv
$ virtualenv -p python3 <env-name>
$ source <env-name>/bin/activate
$ pip install django
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
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>
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
User Authentication
 authenticate()
 login()
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.
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
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
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.
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
Any Queries?
Reach Us
Email id: hello@micropyramid.com
Meetup:
http://www.meetup.com/hyderabad-python-
and-django-meetup-group/
Blog: https://micropyarmid.com/blog/
Github: https://github.com/MicroPyramid/

More Related Content

Social login integration

  • 1. Social Login integration hello Hands On Session 20th May, 2017 Hyderabad Sponsored By
  • 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
  • 5. Django Installation $ sudo apt-get install python-setuptools python-dev build-essential tree $ sudo apt-get install python-pip python-virtualenv $ virtualenv -p python3 <env-name> $ source <env-name>/bin/activate $ pip install django
  • 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
  • 16. Reach Us Email id: hello@micropyramid.com Meetup: http://www.meetup.com/hyderabad-python- and-django-meetup-group/ Blog: https://micropyarmid.com/blog/ Github: https://github.com/MicroPyramid/