与Facebook,但验证code socialauth-的Andr​​oid授权全成为null [英] socialauth-android authorization successfull with Facebook but verification code is null

查看:127
本文介绍了与Facebook,但验证code socialauth-的Andr​​oid授权全成为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用socialauth-的Andr​​oid让我的Andr​​oid用户在Facebook上验证身份。

我的问题如下:

我可以成功地在页面中显示Facebook的日志,用户可以输入凭据并授权我的应用程序。
当授权完成后,挂在SocialAuthAdapter的ReponseListener回调方法的onComplete被调用。

这从未发生过,因为我得到了一个异常说,核查code为null,但我可以在我的应用程序已授权Facebook用户页面上看到。

看来,成功授权后,验证code也由供应商预期,使客户可以将其包含在接下来的请求。

我如果空code是用户会话令牌或别的东西以前也没搞明白。

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

我已经配置了我的Facebook应用程序的原生Android应用程序如图片所示

在code的简化版本中。

 公共类LoginActivity延伸活动{私有静态最后弦乐LOG_TAG =LoginActivity;SocialAuthAdapter适配器;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_login);    适配器=新SocialAuthAdapter(新ResponseListener());            // [......]
}
/ **
*当我的Facebook按钮,用户点击发起调用此方法
*与Facebook的身份验证过程
* /
保护无效doLogin(){
    adapter.authorize(这一点,Provider.FACEBOOK);
}私人final类ResponseListener实现DialogListener {   @覆盖
   公共无效的onComplete(束值){     //变量收到消息状态
     如果(Log.isLoggable(LOG_TAG,Log.DEBUG)){
       Log.d(LOG_TAG,验证成功);
     }     adapter.getUserProfileAsync(新SocialAuthListener<&档案GT;(){        @覆盖
        公共无效onerror的(SocialAuthError为arg0){           Log.e(LOG_TAG,无法检索用户配置文件);        }        @覆盖
        公共无效onExecute(PROFILE资料){           Log.d(LOG_TAGValidatedId =+ profile.getValidatedId());     });  }

堆栈跟踪是

 检索访问令牌在验证响应函数
验证从供应商的认证响应
org.brickred.socialauth.exception.SocialAuthException:验证code为null
在org.brickred.socialauth.oauthstrategy.OAuth2.verifyResponse(OAuth2.java:114)
在org.brickred.socialauth.oauthstrategy.OAuth2.verifyResponse(OAuth2.java:102)
在org.brickred.socialauth.provider.FacebookImpl.doVerifyResponse(FacebookImpl.java:164)
在org.brickred.socialauth.provider.FacebookImpl.verifyResponse(FacebookImpl.java:154)
在org.brickred.socialauth.SocialAuthManager.connect(SocialAuthManager.java:183)
在org.brickred.socialauth.android.SocialAuthDialog$SocialAuthWebViewClient$1.run(SocialAuthDialog.java:243)
在java.lang.Thread.run(Thread.java:856)
org.brickred.socialauth.exception.SocialAuthException:验证code为null
org.brickred.socialauth.android.SocialAuthError:未知的错误


解决方案

<一个href=\"http://$c$c.google.com/p/socialauth-android/issues/detail?id=52\">http://$c$c.google.com/p/socialauth-android/issues/detail?id=52

<一个href=\"http://stackoverflow.com/questions/16059447/you-have-already-authorized-yourapp/16145002#16145002\">You已经授权yourapp <​​/A>

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

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

解决方案

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.

这篇关于与Facebook,但验证code socialauth-的Andr​​oid授权全成为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆