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

锁定Auth0为android不返回UserProfile身份验证,第1张

概述我正在使用Lock在我的 Android应用程序中向用户提供登录功能. 这是我的代码:     私人锁锁; private LocalBroadcastManager broadcastManager;private BroadcastReceiver authenticationReceiver = new BroadcastReceiver() { @Override p 我正在使用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");    }};@OverrIDeprotected 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

总结

以上是内存溢出为你收集整理的锁定Auth0为android不返回UserProfile身份验证全部内容,希望文章能够帮你解决锁定Auth0为android不返回UserProfile身份验证所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1132125.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存