@api_view(['POST'])
@permission_classes([AllowAny])
@psa()
def register_by_access_token(request, backend):
token = request.data.get('access_token')
user = request.backend.do_auth(token)
print(request)
if user:
token, _ = Token.objects.get_or_create(user=user)
return Response(
{
'token': token.key
},
status=status.HTTP_200_OK,
)
else:
return Response(
{
'errors': {
'token': 'Invalid token'
}
},
status=status.HTTP_400_BAD_REQUEST,
)
所以上面是代码
这是网址
re_path('api/register-by-access-token/' + r'social/(?P<backend>[^/]+)/$', register_by_access_token),
但一直以来user = request.backend.do_auth(token)
这个东西给出“凭证不正确”的错误
1条答案
按热度按时间xlpyo6sf1#