오늘은 장고의 수많은 기능중 allauth 라이브러리를 사용해 소셜 로그인 기능을 구현해보겠습니다.
먼저 구글 로그인을 추가하겠습니다.
pip install django-allauth
allauth 라이브러리를 추가해줍니다.
django-allauth.readthedocs.io/en/latest/installation.html
Installation — django-allauth 0.43.0 documentation
Post-Installation In your Django root execute the command below to create your database tables: Now start your server, visit your admin pages (e.g. http://localhost:8000/admin/) and follow these steps: Add a Site for your domain, matching settings.SITE_ID
django-allauth.readthedocs.io
해당 사이트로 가시면 allauth 의 메뉴얼의 상세하게 나와있습니다.
INSTALLED_APPS = [
...
# The following apps are required:
'django.contrib.auth',
'django.contrib.messages',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
# ... include the providers you want to enable:
'allauth.socialaccount.providers.google',
setting.py 의 INSTALLED_APPS에 해당항목을 추가해줍니다.
마지막으로 setting.py의 마지막 항목에 SITD_ID = 1을 입력해줍니다.
다음은 urls.py에 path를 설정해주겠습니다.
urlpatterns = [
...
path('accounts/', include('allauth.urls')),
...
]
이제 migrate로 갱신해주겠습니다. 에러가 안뜨면 정상적으로 진행이 된 것입니다.
이제 서버를 실행하시고 admin페이지로 가주시면 social accounts 항목이 생성되었습니다.
이 다음은 https://0ver-grow.tistory.com/991 해당 블로그 참조하시면 좋을것 같습니다.
'TTL > 5주차 ~ 8주차 TIL (9.26 ~ 10.21)' 카테고리의 다른 글
2022-10-05 TIL (장고 템플릿태그) (0) | 2022.10.06 |
---|---|
2022-10-04 TIL (장고django 비밀번호 변경 기능) (0) | 2022.10.05 |
2022-09-29 TIL (인스타그램 클론코딩 프로젝트 SA) (0) | 2022.09.30 |
2022-09-28 TIL (User Model 확장하기) (0) | 2022.09.28 |
2022-09-27 TIL (장고 admin 페이지에 접속 로그 남기기) (1) | 2022.09.28 |