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