发生内部错误. [无效的access_token,错误代码43.] [英] An internal error has occured. [ invalid access_token, error code 43. ]

查看:245
本文介绍了发生内部错误. [无效的access_token,错误代码43.]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Firebase的Facebook凭据无声地登录我的APP两次时,它会返回此错误消息.

When i sign in my APP silently twice with Facebook credential of Firebase,it return this error message.

An internal error has occured. [ invalid access_token, error code 43. ]

我第一次登录时将Facebook令牌保存在SharedPreferences中,两次登录时将其获取,然后使用FacebookAuthProvider.getCredential(accessToken);创建凭据.最后,我使用以下代码使用此凭据登录:

I save the Facebook token in SharedPreferences when first login,and get it when twice login,then create credential with FacebookAuthProvider.getCredential(accessToken); . At last I sign in with this credential using following code:

private void signInFirebase(AuthCredential credential, final TaskCompleteListener signInListener) {
    FirebaseAuth.getInstance().signInWithCredential(credential)
            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        Logger.i(TAG,"Firebase login success.");
                    } else {
                        Logger.e(TAG,"Firebase login failure:"+task.getException().getMessage());
                    }
                }
            });
}

它总是像标题一样打印. 我尝试过但不起作用的东西:

It always print like title. What i have try,and not work:

1.change Firebase version from 9.0.2 to 9.4.0
2.search error message in Google directly

如何解决这个问题?

推荐答案

Firebase在应用程序重新启动之间已经保持了用户的登录状态.因此,监控用户是否已经存在,而不是自己保留Facebook令牌.通过Firebase进行了身份验证.

Firebase already persists the user's sign-in state between app restarts. So instead of persisting the Facebook token yourself, monitor whether the user is already authenticated with Firebase.

从该文档中获得

FirebaseAuth.getInstance(). addAuthStateListener(new FirebaseAuth.AuthStateListener() {
    @Override
    public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
        FirebaseUser user = firebaseAuth.getCurrentUser();
        if (user != null) {
            // User is signed in
            Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
        } else {
            // User is signed out
            Log.d(TAG, "onAuthStateChanged:signed_out");
        }
        // ...
    }
});

这篇关于发生内部错误. [无效的access_token,错误代码43.]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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