QuickBlox QB.chat.connect给出令人困惑的身份验证错误代码401

QuickBlox QB.chat.connect giving perplexing authentication error code 401 out of nowhere

本文关键字:身份验证 错误代码 chat QB connect QuickBlox      更新时间:2023-09-26

我一直在使用Quickblox应用程序,直到今天下午,当我开始得到一个令人困惑的用户身份验证错误,就像这样:

108 606756 log [QBChat]:, Status. log。AUTHFAIL -认证尝试失败109 606758日志字符串化err…{"代码":401年,"状态":"错误","消息":"未经授权的","细节":"状态。AUTHFAIL -认证尝试失败"}

在chrome中调试时,QBChat中的XML可以扩展,它说'Password not verified',这是令人困惑的,因为密码绝对是正确的。

编辑:我肯定密码是正确的,因为它总是首先成功登录到QuickBlox,但在试图登录到QB时偶尔会失败。聊天服务器。

我不知道是什么引起的。我试着退出登录,在一个空白的石板上重新登录-有时"工作",其他时候它不-所以它可能是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));
              }
            });
          }
        }
      });

有我在控制器中运行的代码…它仍然是随机发生的,有时一连出现很多错误,有时它会出错,然后正常工作,然后错误,然后工作,然后错误,然后工作,等等

啊,原来问题出在Angular JS上。我更改了参数,不再接受$scope.user。使用参数的回调中的密码。从param对象创建的密码进入第一个回调,现在它每次都有效。

收到的错误代码是正确的,这是另一个教训,永远不要停止调查一个特定的趋势,直到你进入brass tacks。

不是假设密码是正确的,因为它每次都成功地完成了第一个QB函数,进一步的调查将表明,角未能向chatparams对象提供变量,因此字段密码不包括在其中-只是{jid: '4353598-350340395@chat.quickblox.com'}。

"未经授权"answers"密码未验证"意味着它的含义-您的聊天登录密码不正确

也许你改变了它通过API或在管理面板?

如果它有时工作-你可以张贴你的代码,将尝试验证可能是什么原因