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

蓝咒 提交于 2020-01-25 20:40:48

问题


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. ]

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

How to solve this problem?


回答1:


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.

From that documentation:

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");
        }
        // ...
    }
});


来源:https://stackoverflow.com/questions/39098093/an-internal-error-has-occured-invalid-access-token-error-code-43

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!