question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do Not Require "Sign In With Google" to sign in with email (screenshots)

See original GitHub issue

Facebook and Facebook Messenger’s In-App browser do not support Google’s OAuth. It throws an error on Google’s end during the redirect saying it doesn’t support that app. disallowed_useragent (iOS Only - works fine on android).

For this reason, when I detect the Facebook in-app browser, I force my users to login with email / password. (I do not include the Google login when Firebaseui initializes)

This works great for new users, they can create / sign in with email and password fine.

The problem is when users have previously created an account with their Google login, and then try to login through the Facebook in-app browser on iOS. They can try using the email / password authentication method, but then, Firebaseui tries to force this user to “sign in with google”, which subsequently throws the disallowed_useragent error.

How can you prevent this from happening, and merge the email / password auth account with the google account? If you create an account with email / password first, and then use Google to login, it works fine. Why not also work the other way around?

        // FirebaseUI config.
        var firebaseui = require('firebaseui');

        // Facebook browser does not support Google Auth
        // Check for Facebook browser
        let browser = null;
        if(typeof navigator !== "undefined" && typeof window !== "undefined") {
            var ua = navigator.userAgent || navigator.vendor || window.opera;
            if ((ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1)) {
                browser = "facebook";
            }
        }

        // Conditionally build signInOptions
        let signInOptions = [];

        // Add Email / Password Auth
        signInOptions.push(firebaseAuth.EmailAuthProvider.PROVIDER_ID);

        // Add Google Auth only if not Facebook browser
        if(browser !== "facebook") {
            signInOptions.push({
                // Google provider must be enabled in Firebase Console to support one-tap sign-up.
                provider: firebaseAuth.GoogleAuthProvider.PROVIDER_ID,
                // Required to enable this provider in one-tap sign-up.
                authMethod: 'https://accounts.google.com',
                // Required to enable ID token credentials for this provider.
                // This can be obtained from the Credentials page of the Google APIs
                // console.
                clientId: 'XXX'
            })
        }

        var uiConfig = {
            signInOptions,
            callbacks: {
                signInSuccessWithAuthResult: function(authResult, redirectUrl) {
                    // Anything we want to happen after signin success
                    
                    // Store user data in the redux store
                    storeUserDataAction(authResult.user);

                    // Auto-send verification email if we have not already done so
                    autoVerifyEmailAction();
                    
                }
            },
            // Terms of service url.
            tosUrl: 'XXX',
            // Required to enable one-tap sign-up credential helper.
            credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOLO
        };

        // Initialize the FirebaseUI Widget using Firebase.
        // Checks to see if we have an existing instance, if not, creates a new one
        var ui = firebaseui.auth.AuthUI.getInstance();
        if (!ui) {
            ui = new firebaseui.auth.AuthUI(firebaseAuth());
        }

        // Auto sign-in for returning users is enabled by default except when prompt is
        // not 'none' in the Google provider custom parameters. To manually disable:
        ui.disableAutoSignIn();

        // The start method only if we're done checking the authState
        ui.start('#fbui-container', uiConfig);
    }

firebaseauthui

disallowed

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
joshualyoncommented, Jul 3, 2018

I appreciate your reiteration.

What I’m saying is I don’t see how step 1 is adding any security in this specific case. In step 2, the account is automatically relinked. So what was the point of automatically unlinking it if it can just be automatically relinked?

1reaction
bojeil-googlecommented, Jul 1, 2018

This is all expected behavior. There are 2 issues here that are unrelated:

  1. password reset unlinks existing providers as @wti806 explained to help users recover from possible account modification (unauthorized providers being linked).
  2. Google sign in overwriting unverified email/password account. Check this post why this happens. This prevents malicious users from creating an account with another user’s email. To avoid this behavior, you need to verify the user’s email after the account is created to confirm ownership of that email so the next time Google is used to sign in, the email/password is preserved.
Read more comments on GitHub >

github_iconTop Results From Across the Web

I'd like my Google Form to not require sign in when they go ...
When I try to pull up the link to fill out the form in Internet Explorer (I am not signed in to Google)...
Read more >
Sharing with non-Google accounts in Google Drive - Dito
Docs, Slides and Drawings can be shared outside your domain to users who do not have a Google account, therefore they will not...
Read more >
Sign in - Google Accounts
Sign in. Use your Google Account. Email or phone. Forgot email? ... Not your computer? Use Guest mode to sign in privately. Learn...
Read more >
Set up Gmail accounts
Training: You can add a gmail account to Microsoft Outlook, and manage it in Outlook, to view and manage all of your email...
Read more >
How to Change Default Gmail Account
If you use the Gmail email service, your Gmail default account is the one that Youtube, Google Drive, contact, or other Google app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found