我想使用python-social-authDjango中的Google Plus登录功能登录用户.从我的网站登录时,一切正常,并将正确的详细信息添加到数据库中.
但是,我也希望从我的Android应用程序进行身份验证.用户登录应用程序,然后应用程序将访问令牌发送到django API,后者根据以下代码处理登录过程,该文档根据文档进行调整:
@csrf_exempt
@serengeti_api_request
@psa('social:complete')
def login_social_token(request, backend):
# Ensure the token has been specified.
token = request.META.get('HTTP_ACCESSTOKEN')
if token is None:
raise SerengetiApiRequestException('Access token is missing!')
# Login the user for this session
user = request.backend.do_auth(token)
if user is None:
raise SerengetiApiRequestException('Could not authenticate user!')
login(request, user)
# Store the email address if one has been specified (e.g. Twitter)
email = request.META.get('HTTP_EMAIL')
if email is not None:
user.email = email
user.save()
# Prepare …Run Code Online (Sandbox Code Playgroud) django django-socialauth google-login python-2.7 python-social-auth