Java Code Examples for com.google.firebase.auth.EmailAuthProvider#PROVIDER_ID

The following examples show how to use com.google.firebase.auth.EmailAuthProvider#PROVIDER_ID . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignInKickstarter.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
private void redirectSignIn(String provider, String id) {
    switch (provider) {
        case EmailAuthProvider.PROVIDER_ID:
            setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                    EmailActivity.createIntent(getApplication(), getArguments(), id),
                    RequestCodes.EMAIL_FLOW)));
            break;
        case PhoneAuthProvider.PROVIDER_ID:
            Bundle args = new Bundle();
            args.putString(ExtraConstants.PHONE, id);
            setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                    PhoneActivity.createIntent(
                            getApplication(),
                            getArguments(),
                            args),
                    RequestCodes.PHONE_FLOW)));
            break;
        default:
            setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                    SingleSignInActivity.createIntent(
                            getApplication(),
                            getArguments(),
                            new User.Builder(provider, id).build()),
                    RequestCodes.PROVIDER_FLOW)));
    }
}
 
Example 2
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
@NonNull
@AuthUI.SupportedProvider
public static String signInMethodToProviderId(@NonNull String method) {
    switch (method) {
        case GoogleAuthProvider.GOOGLE_SIGN_IN_METHOD:
            return GoogleAuthProvider.PROVIDER_ID;
        case FacebookAuthProvider.FACEBOOK_SIGN_IN_METHOD:
            return FacebookAuthProvider.PROVIDER_ID;
        case TwitterAuthProvider.TWITTER_SIGN_IN_METHOD:
            return TwitterAuthProvider.PROVIDER_ID;
        case GithubAuthProvider.GITHUB_SIGN_IN_METHOD:
            return GithubAuthProvider.PROVIDER_ID;
        case PhoneAuthProvider.PHONE_SIGN_IN_METHOD:
            return PhoneAuthProvider.PROVIDER_ID;
        case EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD:
            return EmailAuthProvider.PROVIDER_ID;
        case EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD:
            return EMAIL_LINK_PROVIDER;
        default:
            return method;
    }
}
 
Example 3
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Translate a Firebase Auth provider ID (such as {@link GoogleAuthProvider#PROVIDER_ID}) to a
 * Credentials API account type (such as {@link IdentityProviders#GOOGLE}).
 */
public static String providerIdToAccountType(
        @AuthUI.SupportedProvider @NonNull String providerId) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            return IdentityProviders.GOOGLE;
        case FacebookAuthProvider.PROVIDER_ID:
            return IdentityProviders.FACEBOOK;
        case TwitterAuthProvider.PROVIDER_ID:
            return IdentityProviders.TWITTER;
        case GithubAuthProvider.PROVIDER_ID:
            return GITHUB_IDENTITY;
        case PhoneAuthProvider.PROVIDER_ID:
            return PHONE_IDENTITY;
        // The account type for email/password creds is null
        case EmailAuthProvider.PROVIDER_ID:
        default:
            return null;
    }
}
 
Example 4
Source File: ProviderUtils.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
public static String providerIdToProviderName(@NonNull String providerId) {
    switch (providerId) {
        case GoogleAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_google);
        case FacebookAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_facebook);
        case TwitterAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_twitter);
        case GithubAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_github);
        case PhoneAuthProvider.PROVIDER_ID:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_phone);
        case EmailAuthProvider.PROVIDER_ID:
        case EMAIL_LINK_PROVIDER:
            return AuthUI.getApplicationContext().getString(R.string.fui_idp_name_email);
        default:
            return null;
    }
}
 
Example 5
Source File: SignedInActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void populateProfile(@Nullable IdpResponse response) {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user.getPhotoUrl() != null) {
        GlideApp.with(this)
                .load(user.getPhotoUrl())
                .fitCenter()
                .into(mUserProfilePicture);
    }

    mUserEmail.setText(
            TextUtils.isEmpty(user.getEmail()) ? "No email" : user.getEmail());
    mUserPhoneNumber.setText(
            TextUtils.isEmpty(user.getPhoneNumber()) ? "No phone number" : user.getPhoneNumber());
    mUserDisplayName.setText(
            TextUtils.isEmpty(user.getDisplayName()) ? "No display name" : user.getDisplayName());

    if (response == null) {
        mIsNewUser.setVisibility(View.GONE);
    } else {
        mIsNewUser.setVisibility(View.VISIBLE);
        mIsNewUser.setText(response.isNewUser() ? "New user" : "Existing user");
    }

    List<String> providers = new ArrayList<>();
    if (user.getProviderData().isEmpty()) {
        providers.add(getString(R.string.providers_anonymous));
    } else {
        for (UserInfo info : user.getProviderData()) {
            switch (info.getProviderId()) {
                case GoogleAuthProvider.PROVIDER_ID:
                    providers.add(getString(R.string.providers_google));
                    break;
                case FacebookAuthProvider.PROVIDER_ID:
                    providers.add(getString(R.string.providers_facebook));
                    break;
                case TwitterAuthProvider.PROVIDER_ID:
                    providers.add(getString(R.string.providers_twitter));
                    break;
                case EmailAuthProvider.PROVIDER_ID:
                    providers.add(getString(R.string.providers_email));
                    break;
                case PhoneAuthProvider.PROVIDER_ID:
                    providers.add(getString(R.string.providers_phone));
                    break;
                case EMAIL_LINK_PROVIDER:
                    providers.add(getString(R.string.providers_email_link));
                    break;
                case FirebaseAuthProvider.PROVIDER_ID:
                    // Ignore this provider, it's not very meaningful
                    break;
                default:
                    providers.add(info.getProviderId());
            }
        }
    }

    mEnabledProviders.setText(getString(R.string.used_providers, providers));
}
 
Example 6
Source File: SignInKickstarter.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void startAuthMethodChoice() {
    // If there is only one provider selected, launch the flow directly
    if (!getArguments().shouldShowProviderChoice()) {
        AuthUI.IdpConfig firstIdpConfig = getArguments().providers.get(0);
        String firstProvider = firstIdpConfig.getProviderId();
        switch (firstProvider) {
            case EMAIL_LINK_PROVIDER:
            case EmailAuthProvider.PROVIDER_ID:
                setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                        EmailActivity.createIntent(getApplication(), getArguments()),
                        RequestCodes.EMAIL_FLOW)));
                break;
            case PhoneAuthProvider.PROVIDER_ID:
                setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                        PhoneActivity.createIntent(
                                getApplication(), getArguments(), firstIdpConfig.getParams()),
                        RequestCodes.PHONE_FLOW)));
                break;
            default:
                redirectSignIn(firstProvider, null);
                break;
        }
    } else {
        setResult(Resource.<IdpResponse>forFailure(new IntentRequiredException(
                AuthMethodPickerActivity.createIntent(getApplication(), getArguments()),
                RequestCodes.AUTH_PICKER_FLOW)));
    }
}
 
Example 7
Source File: AuthMethodPickerActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void populateIdpList(List<IdpConfig> providerConfigs) {

        ViewModelProvider supplier = ViewModelProviders.of(this);
        mProviders = new ArrayList<>();
        for (IdpConfig idpConfig : providerConfigs) {
            @LayoutRes int buttonLayout;

            final String providerId = idpConfig.getProviderId();
            switch (providerId) {
                case GoogleAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_idp_button_google;
                    break;
                case FacebookAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_idp_button_facebook;
                    break;
                case EMAIL_LINK_PROVIDER:
                case EmailAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_provider_button_email;
                    break;
                case PhoneAuthProvider.PROVIDER_ID:
                    buttonLayout = R.layout.fui_provider_button_phone;
                    break;
                case AuthUI.ANONYMOUS_PROVIDER:
                    buttonLayout = R.layout.fui_provider_button_anonymous;
                    break;
                default:
                    if (!TextUtils.isEmpty(
                            idpConfig.getParams().getString(GENERIC_OAUTH_PROVIDER_ID))) {
                        buttonLayout = idpConfig.getParams().getInt(GENERIC_OAUTH_BUTTON_ID);
                        break;
                    }
                    throw new IllegalStateException("Unknown provider: " + providerId);
            }

            View loginButton = getLayoutInflater().inflate(buttonLayout, mProviderHolder, false);
            handleSignInOperation(idpConfig, loginButton);
            mProviderHolder.addView(loginButton);
        }
    }
 
Example 8
Source File: AuthMethodPickerActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@NonNull
private String providerOrEmailLinkProvider(@NonNull String providerId) {
    if (providerId.equals(EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD)) {
        return EmailAuthProvider.PROVIDER_ID;
    }

    return providerId;
}
 
Example 9
Source File: AuthUI.java    From FirebaseUI-Android with Apache License 2.0 4 votes vote down vote up
public EmailBuilder() {
    super(EmailAuthProvider.PROVIDER_ID);
}
 
Example 10
Source File: TestHelper.java    From FirebaseUI-Android with Apache License 2.0 4 votes vote down vote up
public static FlowParameters getFlowParameters(Collection<String> providerIds,
                                               boolean enableAnonymousUpgrade,
                                               AuthMethodPickerLayout customLayout) {
    List<IdpConfig> idpConfigs = new ArrayList<>();
    for (String providerId : providerIds) {
        switch (providerId) {
            case GoogleAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.GoogleBuilder().build());
                break;
            case FacebookAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.FacebookBuilder().build());
                break;
            case TwitterAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.TwitterBuilder().build());
                break;
            case GithubAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.GitHubBuilder().build());
                break;
            case EMAIL_LINK_PROVIDER:
                idpConfigs.add(new IdpConfig.EmailBuilder().enableEmailLinkSignIn()
                        .setActionCodeSettings(ActionCodeSettings.newBuilder().setUrl("URL")
                                .setHandleCodeInApp(true).build()).build());
                break;
            case EmailAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.EmailBuilder().build());
                break;
            case PhoneAuthProvider.PROVIDER_ID:
                idpConfigs.add(new IdpConfig.PhoneBuilder().build());
                break;
            case AuthUI.ANONYMOUS_PROVIDER:
                idpConfigs.add(new IdpConfig.AnonymousBuilder().build());
                break;
            case MICROSOFT_PROVIDER:
                idpConfigs.add(new IdpConfig.MicrosoftBuilder().build());
                break;
            default:
                throw new IllegalArgumentException("Unknown provider: " + providerId);
        }
    }
    return new FlowParameters(
            DEFAULT_APP_NAME,
            idpConfigs,
            AuthUI.getDefaultTheme(),
            AuthUI.NO_LOGO,
            null,
            null,
            true,
            true,
            enableAnonymousUpgrade,
            false,
            null,
            customLayout);
}