获取facebook django allauth的用户名

问题描述 投票:0回答:1

我使用django all-auth制作了一个应用程序。我有以下变量集: -

SITE_ID = 1
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 7
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_SIGNUP_PASSWORD_VERIFICATION = True
SOCIALACCOUNT_AUTO_SIGNUP = True
LOGIN_REDIRECT_URL = "/home/"
ACCOUNT_LOGOUT_ON_GET = True
ACCOUNT_USERNAME_BLACKLIST =[]
ACCOUNT_USERNAME_REQUIRED = False

SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': [
            "email",
            "user_friends"
            ],
        #'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
        'AUTH_PARAMS': { },
        'METHOD': 'oauth2'
        },
    }

问题是django allauth没有保存Facebook用户的用户名,就像在facebook中一样。它采用了第一个名字。如何让allauth在注册时保存facebook的用户名。

python django facebook facebook-graph-api
1个回答
0
投票

希望对你来说还不算太晚。您想要做的是连接到allauth.socialaccount.signals.social_account_added信号,并使用Facebook Graph API将allauth社交帐户id条目转换为Facebook句柄/用户名。

django-allauth docs (signals)user accounts on facebook graph API

© www.soinside.com 2019 - 2024. All rights reserved.