Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QuickBlox Token is required error

I have been using the code examples from the quickblox website however i am getting the following error:

signIn error: Token is required

My code:

QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SEC);
    QBAuth.createSession("test", "test",new QBCallbackImpl() {
        @Override
        public void onComplete(Result result) {
            if (result.isSuccess()) {
                // result comes here if authorization is success
                Log.d(TAG,"createSession success");
                QBSessionResult qbSessionResult = (QBSessionResult) result;
            }else{
                for(String s: result.getErrors()){
                    Log.d(TAG, "createSession error: " +s);
                }
            }
        }
        });

             //getting error in here
     QBUsers.signIn("test","test", new QBCallbackImpl() {
                    @Override
                    public void onComplete(Result result) {
                        if (result.isSuccess()) {
                            Log.d(TAG,"signIn success");
                            QBUserResult qbUserResult = (QBUserResult) result;
                        } else {
                            for(String s: result.getErrors()){
                                Log.d(TAG, "signIn error: " +s);
                            }
                        }
                    }
                });

The session is created succcessfully and the user "test" exists with the password "test" on the quickblox dashboard under the application.

Please advise what i am doing wrong?

like image 438
Santiago Avatar asked Apr 18 '13 17:04

Santiago


1 Answers

YOu have to call QBUsers.signIn after session creation

    QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SEC);
    QBAuth.createSession("test", "test",new QBCallbackImpl() {
        @Override
        public void onComplete(Result result) {
            if (result.isSuccess()) {

                QBUsers.signIn("test","test", new QBCallbackImpl() {
                    @Override
                    public void onComplete(Result result) {
                        if (result.isSuccess()) {
                            Log.d(TAG,"signIn success");
                            QBUserResult qbUserResult = (QBUserResult) result;
                        } else {
                            for(String s: result.getErrors()){
                                Log.d(TAG, "signIn error: " +s);
                            }
                        }
                    }
                });


            }else{
                for(String s: result.getErrors()){
                    Log.d(TAG, "createSession error: " +s);
                }
            }
        }
        });
like image 95
Rubycon Avatar answered Sep 28 '22 13:09

Rubycon