Bad Authentication Data QuickBlox - Android
Asked Answered
E

2

2

I am working on QuickBlox SDK , Using this SDK I am trying to login on Facebook . I have visited some helpfull links on stackoverflow like this , but it didn't help me . Here is my code snippet .

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

    }
});

LogCat Details :

Access-Control-Allow-Origin=*
    Cache-Control=no-cache
    Connection=keep-alive
    Content-Length=38
    Content-Type=application/json; charset=utf-8
    Date=Sat, 16 Jan 2016 08:14:28 GMT
    QB-Token-ExpirationDate=2016-01-16 10:14:03 UTC
    QuickBlox-REST-API-Version=0.1.1
    Server=nginx/1.8.0
    Status=422 Unprocessable Entity
    X-Rack-Cache=invalidate, pass
    X-Request-Id=c350c40caa43dae4fa962da7f2e8e389
    X-Runtime=0.132058
    X-UA-Compatible=IE=Edge,chrome=1
  BODY
    '{"errors":["Bad Authentication data"]}'
Envelop answered 16/1, 2016 at 8:25 Comment(0)
P
2

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

Philosophical answered 18/1, 2016 at 13:23 Comment(3)
Thank you for your answer .Envelop
I have fixed this issue a day :).Envelop
I am working with stickers library version 0.8.2 . I am getting an issue here . Here is the link #34948103 . Help me plz .Envelop
E
2

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();
            }
        });


    }
Envelop answered 18/1, 2016 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.