我正在尝试使用 Django Social Auth 实现 Twitter 登录。我添加了一个部分管道,我使用表单(DOB、电子邮件等)从用户那里收集额外的详细信息。
我的问题是,如果用户已经存在,我想跳过这个管道。但是,当我尝试这样做时,我得到一个 AuthTokenError“令牌错误:缺少未经授权的令牌”,我无法弄清楚原因。
这是导致问题的代码:
def gather_extra_data(backend, details, uid, request, user=None, *args, **kwargs):
social_user = UserSocialAuth.get_social_auth(backend.name, uid)
if social_user:
return redirect('socialauth_complete', backend.name)
if not details.get('email'):
if not request.session.get('saved_email'):
return redirect(request_extra, backend=backend.name)
else:
details['email'] = request.session['saved_email']
details['password'] = request.session['password']
details['first_name'] = request.session['first_name']
details['last_name'] = request.session['last_name']
details['dob'] = request.session['dob']
details['gender'] = request.session['gender']
details['avatar_url'] = request.session['avatar_url']