728x90
Follow this official documents.
https://django-allauth.readthedocs.io/en/latest/installation.html
I just summarized in this post.
poetry add django-allauth
After installation done
Follow this
urls.py
urlpatterns = [
...
path('accounts/', include('allauth.urls')),
...
]
Important! You must include the providers you want to use.
settings.py
AUTHENTICATION_BACKENDS = [
'allauth.account.auth_backends.AuthenticationBackend',
]
INSTALLED_APPS = [
...
# The following apps are required:
'django.contrib.auth',
'django.contrib.messages',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
]
...
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
SOCIALACCOUNT_LOGIN_ON_GET = True
ACCOUNT_LOGOUT_ON_GET = True
SOCIALACCOUNT_PROVIDERS = {
"google": {
"APP": {
"client_id": GOOGLE_CLIENT_ID,
"secret": GOOGLE_CLIENT_SECRET,
"key": "",
}
},
Those detailed options are explained in offical document.
You can see login page with http://127.0.0.1:8000/accounts/google/login/
728x90
'IT > Django' 카테고리의 다른 글
python script에서 django model 얻는법 (0) | 2023.05.23 |
---|---|
UnicodeDecodeError: 'cp949' codec can't decode bytes in position : illegal multibyte sequence (0) | 2023.05.09 |
Django-ninja-extra 튜토리얼(정리중) (1) | 2022.06.30 |
django template에서 query string을 href에 넣는 방법. (0) | 2022.05.31 |
Django query 최적화(select_related, prefetch_related, Prefetch + @ django_auto_prefetching) (0) | 2022.05.25 |