contact@digitalnotebooks.co
Stay Organized, Stay Inspired. Let's Write.

Car Listing: Login Using Google Part 14A

Back To All Notes
  • Notebook: Django Project: Car Listing
  • Speaker: Udemy Instructor Rathan Kumar
  • Date Created: July 21, 2024, 6:12 p.m.
  • Owner: Rosilie

Reference: Youtube video

1. To use the social media for login, we have to install a new package, DJANGO-ALLAUTH. So, in the virtual environment terminal, we type.

$ pip install django-allauth

2. In the CARZONE\SETTINGS.PY, we have to add the new app in the INSTALLED_APPS.

3. Still in the SETTINGS.PY, we add

4..in the CARZONE\URLS.PY, create a new path for the social media links.

5, Run the migrations code. You  have encountered errors for  allauth.account.middleware.AccountMiddleware, REQUESTS, JWT, and cryptography. 

6. You have added the ACCOUNTMIDDLEWARE in middleware and PIP INSTALL each the modules, REQUEST, PYJWT AND CRYPTOGRAPHY.

7. Now when  you run PYTHON MANAGE.PY MIGRATE, it should not show any error and so does running your server.

 

WE CHANGE EXAMPLE.COM FROM THE SITES TAB TO LOCALHOST:8000:

8. For Google Login, add the  CLIENT ID and the SECRET KEY that you should get from https://console.developers.google.com/

Create a NEW PROJECT like Car Listing. Then in the APIs & Services, click on OAuth Consent Screen

 

 

9. In the OAuth Consent Screen, select EXTERNAL and CREATE.

10. Fill in  the required fields and SAVE.

11. Then to create the Client ID and SECRET KEY, click on CREATE CREDENTIALS and select OAuth Client ID.

12. Next select WEB APPLICATIONS and fill in required fields. Take note of the REDIRECT  path as this is the same in our URLS.PY.

13. When you click on CREATE, this should create your Client ID and Secret Key. Add this to your Admin Panel board.

In the course, the SITES that is displayed is LOCALHOST, while in my Admin Panel, it shows EXAMPLE.COM

14. Update now the LOGIN.HTML to link to our Google Sign-in.  Use this documentation how to call the social media login. 

FROM:

TO:

15. When you REGISTER and create a new user, it gives you an error because you have added AUTHENTICATION_BACKEND. So you remove this and to make sure that when the user logins using Google, it is directed to the DASHBOARD, we add this:

16. When you click on Google Sign - In, this shows. Click on CONTINUE 

IF YOU WANT TO GO IMMEDIATELY TO THE SOCIAL MEDIA LOGIN PAGE, WE NEED TO ADD THIS LINE IN OUR SETTINGS.PY. 

 

 

17. ALSO, WHEN YOU SIGN-IN USING GOOGLE, IT CREATES A NEW ACCOUNT WITHOUT THE EMAIL YOU USED DURING REGISTRATION. So, when there is a person with an email like person@gmail.com  with the name Person and when you login using Google using PERSON@GMAILCOM, it creates a new record with the the name PERSON1.

EXAMPLE: WITHOUT registering my account but I signed in using Google with my email add, rosy61625@gmail.com, it creates a new record below in the admin panel;

18. YOU STILL NEED A FACEBOOK DEVELOPER ACCOUNT THAT REQUIRES CONFIRMATION.  SO YOU CANT PROCEED WITH FACEBOOK LOGIN.

19. For LINKEDIN, go to LINKED FOR  DEVELOPERS and select CREATE AN APP. However, you can't do this because it requires an organization and network connection.

For your reference, you can use this Youtube Video



No PDF file attached.

Notebook
Notebook Details
Title: Django Project: Car Listing
Category: Udemy Django Course