I try to authenticate with Digits (SMS/phone verification) and then in its callback on success() to call Firebase custom token authentication. All good, Digits works -> Firebase sends the authentication and actually loges the user in, but the callback of the Firebase onComplete() is not called. If I call signInWithCustomToken() directly without going through Digits, it works like it should, onComplete() it is called and all. What can the problem be? Here is what I have in my onCreate():
AuthConfig.Builder builder = new AuthConfig.Builder();
builder.withAuthCallBack(new AuthCallback() {
@Override
public void success(DigitsSession session, String phoneNumber) {
signInWithCustomToken();
}
@Override
public void failure(DigitsException exception) {
}
});
authConfigDigits = builder.build();
Button digitsButton = (Button) findViewById(R.id.auth_button);
digitsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Digits.authenticate(authConfigDigits);
}
});
and then I have the custom token auth method signInWithCustomToken() itself:
private void signInWithCustomToken() {
String customToken = "eyJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImV4cCI6MTQ5Mzg0MDU5MiwiaWF0IjoxNDkzODM2OTkyLCJpc3MiOiJmaXJlYmFzZS1hZG1pbnNkay0xOXBqY0Btb3ZlY2VudHJhbC0zOGUzYS5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsInN1YiI6ImZpcmViYXNlLWFkbWluc2RrLTE5cGpjQG1vdmVjZW50cmFsLTM4ZTNhLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwidWlkIjoic29tZS11aWQifQ.QdyviQ8vMhpMF7VJP949PdjVBwqM4EbZGxJvhCQtsRloJdIc16FPBG_RrBp2wZivWC-z1TIx1yctdMVGsoDAk5ptp-HlNyp5n31DyfZriGgo8zbhWln4RGG4wGYb7hSxGpyvm4STOM9N7TBBKt4lCZFYdpHVbT2idhr0hipxKCC_Ubjhwbjsfxrj5h59GHSyAdjw_yigNBHEtvsUfdGfzwKn_EW5qm5OAA0icCiqjnvsvW5RkwWKo7kWxqZT87-BoHsf5JguFeLGs0Ow9lgxAS2mSuuvni5qiYdLZdOKhu204Ctsty1pyFYrAWwWdnSrTWJwdkBx9xPgsE5UlipkRQ";
mFirebaseAuth.signInWithCustomToken(customToken)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Log.e(TAG, "Task is successfull");
openMainActivity();
} else {
Log.e(TAG, "Task failed");
}
}
});
}