use of com.firebase.ui.auth.FirebaseUiException in project FirebaseUI-Android by firebase.
the class GoogleSignInHandler method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode != RequestCodes.GOOGLE_PROVIDER) {
return;
}
try {
GoogleSignInAccount account = GoogleSignIn.getSignedInAccountFromIntent(data).getResult(ApiException.class);
setResult(Resource.forSuccess(createIdpResponse(account)));
} catch (ApiException e) {
if (e.getStatusCode() == CommonStatusCodes.INVALID_ACCOUNT) {
// If we get INVALID_ACCOUNT, it means the pre-set account was not available on the
// device so set the email to null and launch the sign-in picker.
mEmail = null;
start();
} else if (e.getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CURRENTLY_IN_PROGRESS) {
// Hack for https://github.com/googlesamples/google-services/issues/345
// Google remembers the account so the picker doesn't appear twice for the user.
start();
} else if (e.getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CANCELLED) {
setResult(Resource.forFailure(new UserCancellationException()));
} else {
if (e.getStatusCode() == CommonStatusCodes.DEVELOPER_ERROR) {
Log.w(TAG, "Developer error: this application is misconfigured. " + "Check your SHA1 and package name in the Firebase console.");
}
setResult(Resource.forFailure(new FirebaseUiException(ErrorCodes.PROVIDER_ERROR, "Code: " + e.getStatusCode() + ", message: " + e.getMessage())));
}
}
}
use of com.firebase.ui.auth.FirebaseUiException in project FirebaseUI-Android by firebase.
the class EmailLinkCatcherActivity method initHandler.
private void initHandler() {
mHandler = new ViewModelProvider(this).get(EmailLinkSignInHandler.class);
mHandler.init(getFlowParams());
mHandler.getOperation().observe(this, new ResourceObserver<IdpResponse>(this) {
@Override
protected void onSuccess(@NonNull IdpResponse response) {
finish(RESULT_OK, response.toIntent());
}
@Override
protected void onFailure(@NonNull final Exception e) {
if (e instanceof UserCancellationException) {
finish(RESULT_CANCELED, null);
} else if (e instanceof FirebaseAuthAnonymousUpgradeException) {
IdpResponse res = ((FirebaseAuthAnonymousUpgradeException) e).getResponse();
finish(RESULT_CANCELED, new Intent().putExtra(ExtraConstants.IDP_RESPONSE, res));
} else if (e instanceof FirebaseUiException) {
int errorCode = ((FirebaseUiException) e).getErrorCode();
if (errorCode == ErrorCodes.EMAIL_LINK_WRONG_DEVICE_ERROR || errorCode == ErrorCodes.INVALID_EMAIL_LINK_ERROR || errorCode == ErrorCodes.EMAIL_LINK_DIFFERENT_ANONYMOUS_USER_ERROR) {
buildAlertDialog(errorCode).show();
} else if (errorCode == ErrorCodes.EMAIL_LINK_PROMPT_FOR_EMAIL_ERROR || errorCode == ErrorCodes.EMAIL_MISMATCH_ERROR) {
startErrorRecoveryFlow(RequestCodes.EMAIL_LINK_PROMPT_FOR_EMAIL_FLOW);
} else if (errorCode == ErrorCodes.EMAIL_LINK_CROSS_DEVICE_LINKING_ERROR) {
startErrorRecoveryFlow(RequestCodes.EMAIL_LINK_CROSS_DEVICE_LINKING_FLOW);
}
} else if (e instanceof FirebaseAuthInvalidCredentialsException) {
startErrorRecoveryFlow(RequestCodes.EMAIL_LINK_PROMPT_FOR_EMAIL_FLOW);
} else {
finish(RESULT_CANCELED, IdpResponse.getErrorIntent(e));
}
}
});
}
Aggregations