socialauth-android authorization successfull with Facebook but verification code is null

删除回忆录丶 提交于 2019-12-12 14:07:57

问题


I'm using socialauth-android to let my Android users authenticate themselves on Facebook.

My issue as follows:

I can successfully display the Facebook log in page where the user can enter the credentials and authorize my app. When the authorization is complete, the callback method onComplete of the ReponseListener linked to SocialAuthAdapter should be invoked.

This never happens as I got an exception saying that the verification code is null but I can see on the facebook user page that my app has been authorized.

It seems that after the successful authorization, a verification code is also expected by the provider so that the client can include it in the next requests.

I've also not understood if this null code is the user session token or something else.

Has anyone encountered a similar issue? How to resolve it?

I've configured my Facebook app as Native Android App as shown in the picture

The simplified version of the code is shown.

public class LoginActivity extends Activity {

private static final String LOG_TAG = "LoginActivity";

SocialAuthAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    adapter = new SocialAuthAdapter(new ResponseListener());

            //  [.....]
}
/**
* This method is invoked when the user click on my Facebook button to initiate the
* the authentication process with Facebook
*/
protected void doLogin(){
    adapter.authorize(this, Provider.FACEBOOK);
}

private final class ResponseListener implements DialogListener {

   @Override
   public void onComplete(Bundle values) {

     // Variable to receive message status
     if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
       Log.d(LOG_TAG, "Authentication Successful"); 
     }

     adapter.getUserProfileAsync(new SocialAuthListener<Profile>() {

        @Override
        public void onError(SocialAuthError arg0) {

           Log.e(LOG_TAG, "Cannot retrieve user profile");

        }

        @Override
        public void onExecute(Profile profile) {

           Log.d(LOG_TAG, "ValidatedId = " + profile.getValidatedId()); 

     });

  }

The stacktrace is

Retrieving Access Token in verify response function
Verifying the authentication response from provider
org.brickred.socialauth.exception.SocialAuthException: Verification code is null
at org.brickred.socialauth.oauthstrategy.OAuth2.verifyResponse(OAuth2.java:114)
at org.brickred.socialauth.oauthstrategy.OAuth2.verifyResponse(OAuth2.java:102)
at  org.brickred.socialauth.provider.FacebookImpl.doVerifyResponse(FacebookImpl.java:164)
at org.brickred.socialauth.provider.FacebookImpl.verifyResponse(FacebookImpl.java:154)
at org.brickred.socialauth.SocialAuthManager.connect(SocialAuthManager.java:183)
at  org.brickred.socialauth.android.SocialAuthDialog$SocialAuthWebViewClient$1.run(SocialAuthDialog.java:243)
at java.lang.Thread.run(Thread.java:856)
org.brickred.socialauth.exception.SocialAuthException: Verification code is null
org.brickred.socialauth.android.SocialAuthError: Unknown Error

回答1:


http://code.google.com/p/socialauth-android/issues/detail?id=52

You have already authorized yourapp

This has been fixed and answered on a similar question. Just Update the jars and remove previous ones. Keep in mind that it (jars) is still on testing stage.



来源:https://stackoverflow.com/questions/15986651/socialauth-android-authorization-successfull-with-facebook-but-verification-code

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