QuickBlox QB.chat.connect 莫名其妙地给出了令人费解的身份验证错误代码 401
QuickBlox QB.chat.connect giving perplexing authentication error code 401 out of nowhere
我一直在尝试使用 Quickblox 应用程序并且一切正常(至少在使用用户帐户登录时是这样......)直到今天下午我开始遇到令人困惑的用户身份验证错误像这样:
108 606756 日志 [QBChat]:, Status.AUTHFAIL - 身份验证尝试失败
109 606758 日志字符串化错误... {"code":401,"status":"error","message":"Unauthorized","detail":"Status.AUTHFAIL - The authentication attempt failed"}
在Chome中调试时,QBChat中的XML可以展开,显示'Password not verified',这个密码肯定是对的,很费解
编辑:我肯定密码是正确的,因为它总是首先成功登录到 QuickBlox,但在尝试登录到 QB.CHAT 服务器时偶尔会失败。
我不知道是什么原因造成的。我尝试注销并在空白状态下重新登录 - 有时 'works',其他时候则不然 - 所以据我所知,quickblox 可能只是随机决定工作
$scope.signInClick = function() {
console.log('Login was clicked');
$scope.loading = $ionicLoading.show({
content: 'Logging in',
animation: 'fade-in',
showBackdrop: true,
maxWidth: 200,
showDelay: 0
});
var params = {'login': ($scope.user.username), 'password': ($scope.user.password)}
console.log("params... " + JSON.stringify(params));
QB.users.create(params, function(err, user){
if (user) {
console.log("successful user.create... " + JSON.stringify(user));
var jid = user.id + "-23837" + "@chat.quickblox.com";
console.log(user.login + "'s jid is......" + jid);
var chatparams = {'jid': jid, 'password': ($scope.user.password)};
QB.chat.connect(chatparams, function(err, roster) {
console.log("err from qb.chat.connect... " + JSON.stringify(err));
console.log("roster from qb.chat.connect .... " + JSON.stringify(roster));
});
}
else {
console.log(JSON.stringify(err));
if (err.message == "Unprocessable Entity"){
QB.login(params, function(err, user){
if (user) {
console.log("Logged into QB with " + JSON.stringify(user));
var jid = user.id + "-23837" + "@chat.quickblox.com";
console.log(user.login + "'s jid is......" + jid);
var chatparams = {'jid': jid, 'password': ($scope.user.password)};
QB.chat.connect(chatparams, function(err, roster) {
console.log("stringifying the err... " + JSON.stringify(err));
console.log("stringifying the roster... " + JSON.stringify(roster));
});
}
else {
console.log(JSON.stringify(err));
}
});
}
}
});
控制器中有我 运行 的代码...它仍在随机发生,有时连续出现很多错误,有时会出错,然后工作,然后出错工作然后工作然后错误然后工作等等。
"Unauthorized"和"Password not verified"是什么意思——您的聊天登录密码不正确。
也许您是通过 API 或在管理面板中更改的?
如果它有时有效 - 你可以 post 你的代码,将尝试验证可能是什么原因
啊原来是AngularJS的问题。我将参数从在回调中接受 $scope.user.password 更改为使用创建的参数对象中的 params.password 进入第一个回调,现在每次都有效。
收到的错误代码是正确的,这是另一个教训,在您着手解决问题之前,永远不要停止调查特定趋势。
不是假设密码是正确的,因为它每次都成功完成了第一个 QB func,进一步的调查会表明 angular 未能将变量提供给 chatparams 对象,这样字段其中不包含密码 - 只是 {jid: '4353598-350340395@chat.quickblox.com'}.
我一直在尝试使用 Quickblox 应用程序并且一切正常(至少在使用用户帐户登录时是这样......)直到今天下午我开始遇到令人困惑的用户身份验证错误像这样:
108 606756 日志 [QBChat]:, Status.AUTHFAIL - 身份验证尝试失败 109 606758 日志字符串化错误... {"code":401,"status":"error","message":"Unauthorized","detail":"Status.AUTHFAIL - The authentication attempt failed"}
在Chome中调试时,QBChat中的XML可以展开,显示'Password not verified',这个密码肯定是对的,很费解
编辑:我肯定密码是正确的,因为它总是首先成功登录到 QuickBlox,但在尝试登录到 QB.CHAT 服务器时偶尔会失败。
我不知道是什么原因造成的。我尝试注销并在空白状态下重新登录 - 有时 'works',其他时候则不然 - 所以据我所知,quickblox 可能只是随机决定工作
$scope.signInClick = function() {
console.log('Login was clicked');
$scope.loading = $ionicLoading.show({
content: 'Logging in',
animation: 'fade-in',
showBackdrop: true,
maxWidth: 200,
showDelay: 0
});
var params = {'login': ($scope.user.username), 'password': ($scope.user.password)}
console.log("params... " + JSON.stringify(params));
QB.users.create(params, function(err, user){
if (user) {
console.log("successful user.create... " + JSON.stringify(user));
var jid = user.id + "-23837" + "@chat.quickblox.com";
console.log(user.login + "'s jid is......" + jid);
var chatparams = {'jid': jid, 'password': ($scope.user.password)};
QB.chat.connect(chatparams, function(err, roster) {
console.log("err from qb.chat.connect... " + JSON.stringify(err));
console.log("roster from qb.chat.connect .... " + JSON.stringify(roster));
});
}
else {
console.log(JSON.stringify(err));
if (err.message == "Unprocessable Entity"){
QB.login(params, function(err, user){
if (user) {
console.log("Logged into QB with " + JSON.stringify(user));
var jid = user.id + "-23837" + "@chat.quickblox.com";
console.log(user.login + "'s jid is......" + jid);
var chatparams = {'jid': jid, 'password': ($scope.user.password)};
QB.chat.connect(chatparams, function(err, roster) {
console.log("stringifying the err... " + JSON.stringify(err));
console.log("stringifying the roster... " + JSON.stringify(roster));
});
}
else {
console.log(JSON.stringify(err));
}
});
}
}
});
控制器中有我 运行 的代码...它仍在随机发生,有时连续出现很多错误,有时会出错,然后工作,然后出错工作然后工作然后错误然后工作等等。
"Unauthorized"和"Password not verified"是什么意思——您的聊天登录密码不正确。
也许您是通过 API 或在管理面板中更改的?
如果它有时有效 - 你可以 post 你的代码,将尝试验证可能是什么原因
啊原来是AngularJS的问题。我将参数从在回调中接受 $scope.user.password 更改为使用创建的参数对象中的 params.password 进入第一个回调,现在每次都有效。
收到的错误代码是正确的,这是另一个教训,在您着手解决问题之前,永远不要停止调查特定趋势。
不是假设密码是正确的,因为它每次都成功完成了第一个 QB func,进一步的调查会表明 angular 未能将变量提供给 chatparams 对象,这样字段其中不包含密码 - 只是 {jid: '4353598-350340395@chat.quickblox.com'}.