Bad QuickBlox Authentication Data - Android

I am working on a QuickBlox SDK using this SDK, I am trying to login on Facebook. I visited some useful stackoverflow links, such as, but that 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"]}' 
+2
source share
2 answers

You are using the wrong token

It must be a Facebook token

Please use this guide to integrate the Facebook SDK into your application.

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

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

+1
source

Finally, I got the answer above, I was mistaken for the AccessToken in the QBUsers.signInUsingSocialProvider () method. I need to get AccessToken after successfully logging into facebook 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(); } }); } 
+2
source

All Articles