gpt4 book ai didi

javascript - 获得 200 ok 状态但给出 postman 的响应错误

转载 作者:行者123 更新时间:2023-11-30 20:29:12 26 4
gpt4 key购买 nike

获取响应 200 ok 状态但给出来自 postman 的响应错误波西

 {
"errors": "Unable to log you in, please try again.",
"success": false
}

帖子网址:https://demo.cognitonetworks.com/cognito/gettoken

[{"key":"Content-Type","value":"application/json","description":""}]

@csrf_exempt
def token_new(request):
if request.method == 'POST':
email = request.POST.get('username')
print email
try:
UserObj = CognitoUser.objects.get(user__email=email)
username = UserObj.user.username
group = UserObj.user.groups.filter(name__in=['Admin','Manager'])
group_name = ''
if group:
group_name = group[0].name
except:
return JsonResponseUnauthorized("Unable to log you in, please try again.")
password = request.POST.get('password')

if username and password:
user = authenticate(username=username, password=password)
if user:
TOKEN_CHECK_ACTIVE_USER = getattr(settings, "TOKEN_CHECK_ACTIVE_USER", False)
if TOKEN_CHECK_ACTIVE_USER and not user.is_active:
return JsonResponseForbidden("User account is disabled.")
token = token_generator.make_token(user)
data = {
'token': token,
'user': user.pk,
'userName':UserObj.user.username,
'companyId':UserObj.company.companyid,
'companyApikey':UserObj.company.apikey,
'group_name':group_name
}
request.session['token'] = token
request.session['token'] = user.pk
return JsonResponse(data)
else:
return JsonResponseUnauthorized("Unable to log you in, please try again.")
else:
return JsonError("Must include 'username' and 'password' as POST parameters.")
else:
return JsonError("Must access via a POST request.")

最佳答案

答案很简单,服务器只是接受你的请求并返回给你一个json:

{ "errors": "Unable to log you in, please try again.", "success": false }

问题不在客户端或服务器上,您应该阅读:

Unable to log you in, please try again

关于javascript - 获得 200 ok 状态但给出 postman 的响应错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50546689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com