본문 바로가기
python

구글 네이버 sso 로그인 django 설정 정보

by dev-hyunhyun 2024. 11. 20.

settings.py

INSTALLED_APPS = [
    # sso
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.naver',
]

 

MIDDLEWARE = [
    'allauth.account.middleware.AccountMiddleware',  # sso 미들웨어 추가
]

 

AUTHENTICATION_BACKENDS = [
    # sso
    'allauth.account.auth_backends.AuthenticationBackend',
]
# sso
ACCOUNT_ADAPTER = 'accounts.adapter.CustomAccountAdapter'
SOCIALACCOUNT_ADAPTER = 'accounts.adapter.CustomSocialAccountAdapter'

 

SOCIALACCOUNT_PROVIDERS = {
    'google': {
        'APP': {
            'client_id': '',  # 발급받은 클라이언트 ID
            'secret': '',  # 발급받은 클라이언트 비밀 키
            'key': ''  # 일반적으로 비워둡니다.
        },
        'SCOPE': [
            'profile',  # 기본적인 프로필 정보
            'email',  # 이메일 정보
        ],
        'AUTH_PARAMS': {
            'access_type': 'offline',
        },
        'OAUTH_PKCE_ENABLED': True,  # PKCE 사용
    },
    'naver': {
        'APP': {
            'client_id': '',  # 네이버 Client ID
            'secret': '',  # 네이버 Client Secret
            'key': ''
        }
    }
}

 

구글 콜백 url 예시 - http://127.0.0.1:8000/accounts/google/login/callback/
네이버 콜백 url 예시 - http://127.0.0.1:8000/accounts/naver/login/callback/

'python' 카테고리의 다른 글

django - settings.py 기본 보안 설정  (0) 2025.02.25
uwsgi 자동 시작 설정 [우분투]  (0) 2024.12.26
기본 django 세팅  (0) 2024.08.27
uWSGI 관련  (0) 2024.08.23
깃허브 관련  (0) 2024.08.23