-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogleOAuthSteps.txt
50 lines (32 loc) · 1.15 KB
/
GoogleOAuthSteps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Command to be Executed:
pip install social-auth-app-django
In settings.py file
INSTALLED_APPS = [
...,
'social_django',
'django.contrib.sites',
...,
]
SITE_ID = 1
SOCIAL_AUTH_URL_NAMESPACE = 'social'
AUTHENTICATION_BACKENDS = (
'social_core.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '517781533942-7k02oetvdgm7499hhspp3g6bj6joupk9.apps.googleusercontent.com'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'gCxksmM6r3bJzepJVzafUwfP'
SESSION_COOKIE_SAMESITE = None
LOGIN_URL = '/auth/login/google-oauth2/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
In urls.py
from django.conf import settings
from django.contrib.auth import logout
path('',include('social_django.urls',namespace='social')),
path('logout/', logout, {'next_page': settings.LOGOUT_REDIRECT_URL},name='logout'),
In Anchor Tag For Sign In
<a href="{% url 'social:begin' 'google-oauth2' %}" class="nav-item nav-link active">
Sign In
</a>
Migrate to the database(Necessary)
python manage.py migrate