Bad Authentication Data QuickBlox - Android

蓝咒 提交于 2019-12-02 03:03:17

You use a wrong token

It should be the Facebook token

Please use this guide to integrate Facebook SDK to your app

https://developers.facebook.com/docs/android/getting-started

https://developers.facebook.com/docs/facebook-login/android

Finally I got the answer of the Above Question , I was passing wrong AccessToken in the method QBUsers.signInUsingSocialProvider() . I need to get AccessToken after successfull facebook login using

AccessToken accessToken = loginResult.getAccessToken();

Then I need to pass this accessToken inside QBUsers.signInUsingSocialProvider()

Here is my complete code :

    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            AccessToken accessToken = loginResult.getAccessToken();
            facebooklogin(accessToken);
        }

        @Override
        public void onCancel() {
            // App code
            Toast.makeText(getApplicationContext(), "Cancel", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException exception) {
            // App code
            Toast.makeText(getApplicationContext(), "Error-Check Network Connection", Toast.LENGTH_SHORT).show();
        }

    });

   public void facebooklogin(final AccessToken accessToken) {

        QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
            @Override
            public void onSuccess(QBSession session, Bundle params) {

                String token = accessToken.getToken();

                QBUsers.signInUsingSocialProvider(QBProvider.FACEBOOK, token, null, new QBEntityCallbackImpl<QBUser>() {
                    @Override
                    public void onSuccess(QBUser user, Bundle args) {
                        Toast.makeText(getApplicationContext(), "Success QB", Toast.LENGTH_SHORT).show();
                    }
                    @Override
                    public void onError(List<String> errors) {
                        Toast.makeText(getApplicationContext(), "onError QB", Toast.LENGTH_SHORT).show();
                    }
                });
            }
            @Override
            public void onError(List<String> errors) {
                Toast.makeText(getApplicationContext(), "onError", Toast.LENGTH_SHORT).show();
            }
        });


    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!