Search code examples
gmailsingle-sign-onauth0

Auth0 SSO with multiple google accounts


I'm setting up Auth0 with SSO enabled for multiple web sites.

I have it working perfectly for username/password connections and for google connections where the user is only logged into a single google account.

But... I have two google accounts logged in on my browser. When I go to site 1 and use the google connection, it prompts me to select a google account to log in with. That's correct.

But when I go to site 2, and attempt to stay logged in using sso data from Auth0, it still prompts me to select a google account again. Which I would not expect.

Here's my sign in code:

auth0.getSSOData(function (err, ssoData) {
    if (!err && ssoData.sso) {
        auth0.signin({
            connection: ssoData.lastUsedConnection.name,
            scope: 'openid email email_verified name app_metadata',
            state: 'http://localhost:21763/#/',
            authParams: {
                prompt: 'none'
            }
        });
    }
});

I added prompt: 'none' having read this older post on Auth0 community, but to no avail. https://auth0.com/forum/t/sso-login-with-google-connection-must-select-account/4983

Has anyone else done this? I feel like it must be possible.

Thanks!


Solution

  • I started experimenting with the possible parameters into the signin method call and stumbled across the answer...

    I tried a few things, but this seems to work perfectly, moving the "prompt: 'none'" up out of the authParams to be a direct option to signin method call...

    auth0.getSSOData(function (err, ssoData) {
        if (!err && ssoData.sso) {
            auth0.signin({
                connection: ssoData.lastUsedConnection.name,
                scope: 'openid email email_verified name app_metadata',
                state: 'http://localhost:21763/#/',
                prompt: 'none'
            });
        }
    });