Android 无法在 Quickblox 中创建会话

Unable to create Session in Quickblox in Android

我是 Quickblox 的新手。我正在努力 webrtc。我遵循了教程 here. I have also referred to QuickBlox Error with Custom Object (Android)。当我尝试创建 session:

时出现以下错误

Authentication error: Unable to respond to any of these challenges: {}

D/QBASDK(31816): STATUS : 401

D/QBASDK(31816): '{"errors":["Unauthorized"]}'

我的完整代码粘贴在下面:

  public class MainActivity extends ActionBarActivity implements OnClickListener,
    QBRTCClientSessionCallbacks, QBRTCClientConnectionCallbacks,
    QBRTCClientVideoTracksCallbacks {
QBChatService chatService;
QBUser user1, user2;
QBGLVideoView localVideoVidew;
Button btn_session;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn_session = (Button) findViewById(R.id.btn_session);
    btn_session.setOnClickListener(MainActivity.this);

    /*
     * user1 = new User(1, "User1", "user1", "1234", 1); user2 = new User(2,
     * "User2", "user2", "1234", 2);
     */
    if (!QBChatService.isInitialized()) {
        QBChatService.init(MainActivity.this);
        chatService.getInstance();
    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.btn_session:
        create_session();
        // create_SignallingManager();
        break;

    default:
        break;
    }
}

public void create_SignallingManager() {
    // TODO Auto-generated method stub

    QBChatService
            .getInstance()
            .getVideoChatWebRTCSignalingManager()
            .addSignalingManagerListener(
                    new QBVideoChatSignalingManagerListener() {

                        @Override
                        public void signalingCreated(
                                QBSignaling qbSignaling, boolean arg1) {
                            // TODO Auto-generated method stub
                            if (!arg1) {
                                QBRTCClient.getInstance().addSignaling(
                                        (QBWebRTCSignaling) qbSignaling);
                            }
                        }
                    });
    QBRTCClient.getInstance().setCameraErrorHendler(
            new VideoCapturerAndroid.CameraErrorHandler() {
                @Override
                public void onCameraError(final String s) {
                    MainActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, s,
                                    Toast.LENGTH_LONG).show();
                        }
                    });
                }
            });
    QBRTCClient.getInstance()
            .addSessionCallbacksListener(MainActivity.this);
    QBRTCClient.getInstance().addConnectionCallbacksListener(
            MainActivity.this);
    QBRTCClient.getInstance().addVideoTrackCallbacksListener(
            MainActivity.this);

    QBRTCClient.getInstance().prepareToProcessCalls(MainActivity.this);
}

private void create_session() {
    QBSettings.getInstance().fastConfigInit("XXXX", "XXXXXXX", "XXXXX");//Have put ids properly in code
    final QBUser user = new QBUser("user1", "1234");    
    QBAuth.createSession(user, new QBCallback() {

        @Override
        public void onComplete(Result arg0, Object arg1) {
            // TODO Auto-generated method stub
            QBUsers.signIn(user,new QBCallback() {

                @Override
                public void onComplete(Result arg0, Object arg1) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onComplete(Result arg0) {
                    // TODO Auto-generated method stub
                    if(arg0.isSuccess())
                    {
                        Log.i("working","fine");
                    }
                }
            });

        }

        @Override
        public void onComplete(Result arg0) {
            // TODO Auto-generated method stub

        }
    });




}

@Override
public void onLocalVideoTrackReceive(QBRTCSession arg0,
        QBRTCVideoTrack videoTrack) {
    // TODO Auto-generated method stub
    localVideoVidew = (QBGLVideoView) findViewById(R.id.localVideoView);
    Log.d("TAG", "localVideoVidew is " + localVideoVidew);
    if (localVideoVidew != null) {
        videoTrack.addRenderer(new VideoRenderer(new VideoCallBacks(
                localVideoVidew, QBGLVideoView.Endpoint.LOCAL)));
        localVideoVidew.setVideoTrack(videoTrack,
                QBGLVideoView.Endpoint.LOCAL);
        Log.d("TAG", "onLocalVideoTrackReceive() is raned");
    }
}

@Override
public void onRemoteVideoTrackReceive(QBRTCSession arg0,
        QBRTCVideoTrack arg1, Integer arg2) {
    // TODO Auto-generated method stub

}

@Override
public void onConnectedToUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onConnectionClosedForUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onConnectionFailedWithUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onDisconnectedFromUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onDisconnectedTimeoutFromUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onError(QBRTCSession arg0, QBRTCException arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onStartConnectToUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onCallRejectByUser(QBRTCSession arg0, Integer arg1,
        Map<String, String> arg2) {
    // TODO Auto-generated method stub

}

@Override
public void onReceiveHangUpFromUser(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

@Override
public void onReceiveNewSession(QBRTCSession arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onSessionClosed(QBRTCSession arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onSessionStartClose(QBRTCSession arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onUserNotAnswer(QBRTCSession arg0, Integer arg1) {
    // TODO Auto-generated method stub

}

}

401未经授权

请求需要用户身份验证。基本和摘要访问身份验证"

您缺少 onSuccessMethod().

 QBSettings.getInstance().fastConfigInit("XXXX", "XXXXXXX", "XXXXX");//Have put ids properly in code
    final QBUser user = new QBUser("user1", "1234");

// then the user will be logged in automatically
QBAuth.createSession(login, password, new QBEntityCallbackImpl<QBSession>() {
   @Override
   public void onSuccess(QBSession session, Bundle bundle) {

      user.setId(session.getUserId());                

      // INIT CHAT SERVICE
      if (!QBChatService.isInitialized()) {
         QBChatService.init(this);
         chatService = QBChatService.getInstance();
      }

      // LOG IN CHAT SERVICE
      chatService.login(user, new QBEntityCallbackImpl<QBUser>() {

         @Override
         public void onSuccess() {
            // success
         }

         @Override
         public void onError(List errors) {
            //error
         }
      });
   }

   @Override
   public void onError(List<String> errors) {
      //error
   }
});

未授权表示用户的登录名或密码错误,您应该先检查一下

按照此处的说明使用此方法 http://quickblox.com/developers/Android#How_to:_add_SDK_to_IDE_and_connect_to_the_cloud

注意此创建会话方法没有"User"字段

QBAuth.createSession(新 QBEntityCallbackImpl() {}