Django/Django note
[Django note] #4 내가 보려고 만드는 장고 노트(소셜 로그인 구현)
clean01
2020. 7. 20. 02:30
1. pip install django-allauth로 allauth 설치
2. settings.py에
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites', #얘 추가
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'matapp.apps.MatappConfig',
#allauth 추가
'allauth',
'allauth.account',
'allauth.socialaccount',
#provider : 소셜 로그인을 제공해주는 업체(ex 카카오, 네이버, 구글, 페북 등등)
'allauth.socialaccount.providers.google', #구글, provider이름은 바꿀 수 있음
]
....(생략)
AUTHENTICATION_BACKENDS = (
#Needed to login by username in Django admin, regardless of 'allauth'
'django.contrib.auth.backends.ModelBackend',
#'allauth' specific authentication methods, such as login by e-mail
'allauth.acount.auth_backends.AuthenticationBackend',
) #리스트가 아닌 튜플임. 튜플: 리스트랑 유사하나 값의 순서를 바꿀 수 없고, 삭제, 변경 불가능
SITE_ID = 1
LOGIN_REDIRECT_URL = '/'
3. https://console.developers.google.com/
여기에 접속해서 프로젝트를 만들기
Google Cloud Platform
하나의 계정으로 모든 Google 서비스를 Google Cloud Platform을 사용하려면 로그인하세요.
accounts.google.com
4. html 파일에