3

我正在使用 socialauth-android 让我的 Android 用户在 Facebook 上进行身份验证。

我的问题如下:

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

这永远不会发生,因为我收到一个异常说验证码为空,但我可以在 facebook 用户页面上看到我的应用程序已获得授权。

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

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

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

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

显示了代码的简化版本。

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
4

1 回答 1

4

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

您已经授权您的应用

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

于 2013-04-22T10:48:08.180 回答