in auth/src/main/java/com/firebase/ui/auth/data/remote/SignInKickstarter.java [57:121]
public void start() {
if (!TextUtils.isEmpty(getArguments().emailLink)) {
setResult(Resource.forFailure(new IntentRequiredException(
EmailLinkCatcherActivity.createIntent(getApplication(), getArguments()),
RequestCodes.EMAIL_FLOW)));
return;
}
// Signing in with Generic IDP puts the app in the background - it can be reclaimed by the
// OS during the sign in flow.
Task<AuthResult> pendingResultTask = getAuth().getPendingAuthResult();
if (pendingResultTask != null) {
pendingResultTask
.addOnSuccessListener(
authResult -> {
final IdpResponse response = new IdpResponse.Builder(
new User.Builder(
authResult.getCredential().getProvider(),
authResult.getUser().getEmail()).build())
.build();
handleSuccess(response, authResult);
})
.addOnFailureListener(
e -> setResult(Resource.forFailure(e)));
return;
}
// Only support password credentials if email auth is enabled
boolean supportPasswords = ProviderUtils.getConfigFromIdps(
getArguments().providers, EmailAuthProvider.PROVIDER_ID) != null;
List<String> accountTypes = getCredentialAccountTypes();
// If the request will be empty, avoid the step entirely
boolean willRequestCredentials = supportPasswords || accountTypes.size() > 0;
if (getArguments().enableCredentials && willRequestCredentials) {
setResult(Resource.forLoading());
GoogleApiUtils.getCredentialsClient(getApplication())
.request(new CredentialRequest.Builder()
.setPasswordLoginSupported(supportPasswords)
.setAccountTypes(accountTypes.toArray(new String[accountTypes.size()]))
.build())
.addOnCompleteListener(task -> {
try {
handleCredential(
task.getResult(ApiException.class).getCredential());
} catch (ResolvableApiException e) {
if (e.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
setResult(Resource.forFailure(
new PendingIntentRequiredException(
e.getResolution(), RequestCodes.CRED_HINT)));
} else {
startAuthMethodChoice();
}
} catch (ApiException e) {
startAuthMethodChoice();
}
});
} else {
startAuthMethodChoice();
}
}