我使用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的用户名。
希望对你来说还不算太晚。您想要做的是连接到allauth.socialaccount.signals.social_account_added
信号,并使用Facebook Graph API将allauth社交帐户id
条目转换为Facebook句柄/用户名。
见django-allauth docs (signals)和user accounts on facebook graph API