quickblox-android-sdk: Authentication failed, check user's ID and password

Help avoid duplicate issue reports, check [existing issues](link to issues section of repo)

Environment details (Operating system, browser information, SDK version) Windows 10 | chrome | 3.3.1

Did this work before? No

Expected behavior to create a session and perform a successful authentication…!

Actual behavior

I know that starting from v3.2 creating a session manually isn’t required, but doing that resulted in a crash when I initialized the dialog right before I’m about to start a private chat via this method. chatDialog.initForChat(chatService); and the cause of the error is< Recipient ID is null > SO… I had to create the session manually, but it shows me OnError whenever I call QBChatService.getInstance.login(user, ....) and this error shows… Error chatService :: Authentication failed, check user's ID and password if I tried to make a new dialog while this error still exists, this error shows… base Forbidden. Need user. Logs

https://gist.github.com/AlaaZarifa/c841bf2d1952b578cb6e5307a0d5bca2

Steps to reproduce the behavior

Here’s the Login method…

        final String un = userName.getText().toString();
        final String pw = pass.getText().toString();
        QBUser user = new QBUser(un, pw);

        QBUsers.signIn(user).performAsync(new QBEntityCallback<QBUser>() {
          @Override
          public void onSuccess(QBUser user, Bundle bundle) { 
            Intent i = new Intent(MainActivity.this, ChatDialogsActivity.class);
            i.putExtra("userName", un);
            i.putExtra("pass", pw);
            MainActivity.this.startActivity(i);
          }
          @Override
          public void onError(QBResponseException e) {
          }
        });

Here’s the session creation method… called inside the onCreate of in DialogsActivity

    QBChatService chatService = QBChatService.getInstance();
    String username, pass;
    username = getIntent().getStringExtra("userName");
    pass = getIntent().getStringExtra("pass");
    final QBUser user = new QBUser(username, pass);
    Log.i(">>> user : ", username);
    Log.i(">>> pass : ", pass);

    QBAuth.createSession().performAsync(new QBEntityCallback<QBSession>() {
      @Override
      public void onSuccess(QBSession session, Bundle bundle) {
        user.setId(session.getUserId());
        try {
          user.setPassword(QBSessionManager.getInstance().getToken());
          Log.d("Token ", QBSessionManager.getInstance().getToken() + "");
        } catch (Exception e) {
          Log.d(" Set Password E ", e.getMessage() + ""); }
       
                   chatService.login(user, new QBEntityCallback() {
                             @Override
                             public void onSuccess(Object o, Bundle bundle) {
                               Log.i("Success chatService : ", " ");
                             }
                             @Override
                             public void onError(QBResponseException e) {
/* this what gets called x_x */   Log.i("Error chatService : ", e.getMessage() + ""); 
                             }
                           }); }
              
      @Override
      public void onError(QBResponseException e) {
        Log.d(" createSession ", e.getMessage() + "");

      }
    });

Any others comments?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

yes but before chatService.login(user, new QBEntityCallback() need add user.setPassword(password);

below code for creating session and login to chat for your method

        QBUser qbUser = new QBUser(user,pass);
        QBUsers.signIn(qbUser).performAsync(new QBEntityCallback<QBUser>() {
            @Override
            public void onSuccess(QBUser resultQbUser, Bundle bundle) {
                resultQbUser.setPassword(pass);

                QBChatService.getInstance().login(resultQbUser, new QBEntityCallback() {
                    @Override
                    public void onSuccess(Object o, Bundle bundle) {
                        progressDialog.dismiss();
                    }

                    @Override
                    public void onError(QBResponseException e) {
                        Log.e("ERROR",""+e.getMessage());
                    }
                });
            }

            @Override
            public void onError(QBResponseException e) {
                Log.e("ERROR","+++++HERE++++"+e.getMessage());

            }
        });