锁定Auth0为android不返回UserProfile身份验证

我正在使用Lock在我的 Android应用程序中向用户提供登录功能.

这是我的代码:
私人锁锁;

private LocalBroadcastManager broadcastManager;

private BroadcastReceiver authenticationReceiver = new BroadcastReceiver() {

    @Override
    public void onReceive(Context context,Intent intent) {
        String idToken = intent.getStringExtra("com.auth0.android.lock.extra.IdToken");
        String tokenType = intent.getStringExtra("com.auth0.android.lock.extra.TokenType");
        Log.i(TAG,"User  logged in with " + idToken + " "+ tokenType);
    }
};

//Not sure use of this callback  though its not being called anytime.
private LockCallback callback = new AuthenticationCallback() {
    @Override
    public void onAuthentication(Credentials credentials) {
        Log.d(TAG,"Authenticated");
    }

    @Override
    public void onCanceled() {
        Log.d(TAG,"Authentication cancelled");
    }

    @Override
    public void onError(LockException error) {
        Log.d(TAG,"Authentication Error");
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Auth0 auth0 = new Auth0(getString(R.string.auth0_clientId),getString(R.string.auth0_domain));
    this.lock = Lock.newBuilder(auth0,callback)
            .build();
    broadcastManager = LocalBroadcastManager.getInstance(this);
    broadcastManager.registerReceiver(authenticationReceiver,new IntentFilter("com.auth0.android.lock.action.Authentication"));
    startActivity(this.lock.newIntent(this));
}

我有以下两个问题:
1).首先我不明白为什么它需要回调,尽管即使认证成功后它也不回调.
2). LocalBroadcastManager不应该使用UserProfile信息而不是令牌信息来获取响应?

我使用的是Lock版本:com.auth0.android:lock:2.0.0-beta.2

有什么更好的办法吗?

提前致谢!

解决方法

你尝试过onSuccess方法吗?我无法看到你的代码,这就是为什么它不成功尝试后执行.

在您的LockCallback回调中覆盖onSuccess方法,这将返回UserProfile.

/**
 * Callback for authentication API calls to Auth0 API.
 */
public interface AuthenticationCallback extends Callback {

    /**
     * Called when authentication is successful.
     * It might include user's profile and token information.
     * @param profile User's profile information or null.
     * @param token User's token information (e.g. id_token).
     */
    void onSuccess(UserProfile profile,Token token);

}

Source

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...