gpt4 book ai didi

ios - 平衡支付的 401 权限错误

转载 作者:行者123 更新时间:2023-11-28 22:02:42 25 4
gpt4 key购买 nike

我正在使用 Parse.Cloud.httpRequest,我需要将仅包含用户名的基本身份验证发送到平衡支付。这会去哪里,那会是什么样子?我尝试在标题中设置它,但这不起作用。

 Parse.Cloud.httpRequest({
method:'POST',
url: customerUrl,
headers:{
"Content-Type" : "application/x-www-form-urlencoded",
"Accept" : "application/vnd.api+json;revision=1.1",
"Authorization" : balancedSecret
},
body:bodyJsonString,
success: function(httpResponse) {
console.log(httpResponse.text);
response.success(httpResponse.text);
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error(httpResponse.text);

}
});

当我调用我得到的函数时:

"errors": [
{
"status": "Unauthorized",
"category_code": "authentication-required",
"description": "Not permitted to perform create on customers. Your request id is OHMca9c440a0a7811e4ba9202a1fe52a36c.",
"status_code": 401,
"category_type": "permission",
"request_id": "OHMca9c440a0a7811e4ba9202a1fe52a36c"
}
]

最佳答案

"Authorization"  : balancedSecret

这是错误的。您使用 secret 作为用户名,没有任何内容作为密码。然后将它们连接在一起,对它们进行 base64 编码,并将 that 作为 auth header 的值传递。

我没有设置来仔细检查这个,但这应该作为值:

"Basic " + encodeBase64(balancedSecret + ":")

提供此代码:

authHeader = "Basic " + btoa(balancedSecret + ":")
Parse.Cloud.httpRequest({
method:'POST',
url: customerUrl,
headers:{
"Content-Type" : "application/x-www-form-urlencoded",
"Accept" : "application/vnd.api+json;revision=1.1",
"Authorization" : authHeader
},
body:bodyJsonString,
success: function(httpResponse) {
console.log(httpResponse.text);
response.success(httpResponse.text);
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error(httpResponse.text);

}
});

关于ios - 平衡支付的 401 权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24721888/

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