lockingAuth0的Android没有返回UserProfile身份validation

我正在使用锁在我的android应用程序中为用户提供loginfunction。

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

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)。 首先,我不明白为什么它需要callback,尽pipe即使authentication成功,它也不回叫。 2)。 LocalBroadcastManager不应该使用UserProfile信息而不是令牌信息来响应?

我正在使用锁版本:com.auth0.android:lock:2.0.0-beta.2

有没有更好的方法来做到这一点?

提前致谢!

Solutions Collecting From Web of "lockingAuth0的Android没有返回UserProfile身份validation"

你有没有尝试过成功的方法? 我不能看到你的代码,这就是为什么成功尝试后不执行。

在你的LockCallback callback覆盖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 (eg id_token). */ void onSuccess(UserProfile profile, Token token); } 

资源