Search code examples
androidquickblox

user registration error: Token is required


I want to create registration in chat.

In application.java onCreate I use:

        QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY, AUTH_SECRET);
    StickersManager.initialize(STICKER_API_KEY, this);
    ChatService.initIfNeed(this);

In my activity I use:

            ChatService.initIfNeed(EditProfileActivity.this);

            final QBUser chatUser = new QBUser("userlogin", "userpass");
            QBUsers.signUp(chatUser, new QBEntityCallbackImpl<QBUser>() {
                @Override
                public void onSuccess(QBUser user, Bundle args) {
                    // success
                    Log.e("chat", "registered");
                }

                @Override
                public void onError(List<String> errors) {
                    // error
                    Log.e("chat", "registration error");
                }
            });

but getting next error in OnError: Token is required

Which token is it needed? How to register new user from user app?


Solution

  • To be able to use QuickBlox API you have to create a session.

    http://quickblox.com/developers/Android#A_couple_of_words_about_Authentication_and_Authorization

    QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
        @Override
        public void onSuccess(QBSession session, Bundle params) {
            // success
            // you can sign up user here
        }
    
        @Override
        public void onError(List<String> errors) {
            // errors
        }
    });