socialauth-android授权使用Facebook成功,但验证码为空

时间:2013-04-13 10:09:58

标签: android facebook socialauth

我正在使用socialauth-android让我的Android用户在Facebook上验证自己。

我的问题如下:

我可以成功显示Facebook登录页面,用户可以在其中输入凭据并授权我的应用程序。 授权完成后,应调用链接到SocialAuthAdapter的ReponseListener的回调方法onComplete。

这种情况从未发生,因为我得到一个例外情况,说验证码为空但我可以在Facebook用户页面上看到我的应用已被授权。

在成功授权之后,似乎提供商也需要验证码,以便客户端可以将其包含在下一个请求中。

我也不明白这个空代码是用户会话令牌还是其他东西。

有没有人遇到过类似的问题? 如何解决?

我已将我的Facebook应用程序配置为原生Android应用程序,如图所示 **Facebook App configuration**

显示了代码的简化版本。

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

     });

  }

堆栈跟踪是

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 个答案:

答案 0 :(得分:4)

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

<强> You have already authorized yourapp

这已得到修复并回答了类似的问题。只需更新罐子并删除以前的罐子。请记住,它(罐子)仍处于测试阶段。