Google Identity Service auto sign-in

Viewed 724

This is a very simple version of the code we have that's failing.

Following the guidance on Automatic Sign-in we have a very simple web page:

<html>
<head>
    <title>Google Signin Testing</title>
    <script src="https://accounts.google.com/gsi/client" async defer></script>

    <script>
    function onSignIn(credentialResponse) {
        document.body.innerHTML = "Signed in";
    }
    </script>
</head>
<body>
    <div
    id="g_id_onload"
    data-client_id=<our-client-id>
    data-context="signin"
    data-ux_mode="popup"
    data-callback="onSignIn"
    data-auto_select="true"
    ></div>

    <!--<div class="g_id_signin"
                    data-type="standard"
                    data-shape="rectangular"
                    data-theme="outline"
                    data-text="signin_with"
                    data-size="large"
                    data-logo_alignment="left">
                </div>-->
</body>
</html>

Because data-auto_select="true" this should automatically sign-in without having to sign in each time the user reloads the page. But that's not what's happening: https://games.tactiletimes.org/signin.html

What are we missing?

2 Answers

We were logged in to Google with multiple accounts, so the auto sign-in did not know which one we wanted to use for the page. The documentation (here) says:

If a user has multiple Google accounts and visits your site they are required to first sign-in to a single Google account

If I sign out of all accounts on Google, and then sign into Google with just one of my accounts, then the auto sign-in works on our pages.

The previous Google authentication APIs did not have this requirement.

It's worth noting that the previous versions of the Authentication SDKs did not offer Automatic sign-in. It's a new user flow with a new and different set of requirements. The two other user flows: One Tap and the Sign In With Google button may be more what you're expecting; both offer the ability to use an account chooser as part of the normal flow.

To expand on this slightly; choosing one Google Account and signing into that account are required steps, if a device or browser has an active session with the Google Account the account choice and sign-in step may be skipped. That's automatic sign-in in a nutshell.

Related