gapi.auth2.getAuthInstance().signIn() automatically signs in the previous user after signOut()

Viewed 260

When you sign out the currently signed-in user with:

gapi.auth2.getAuthInstance().signOut();

And then call:

gapi.auth2.getAuthInstance().signIn();

The previously signed-in user will automatically get signed in again.

How do I instead show the option to sign in with a different Google account? Does signOut() not actually sign out the user?

1 Answers

You can force showing the account selection screen by passing the prompt SignInOptions option to signIn():

gapi.auth2.getAuthInstance().signIn({
    prompt: 'select_account'
});

signOut() signs the user out of your app without signing them out of Google. Therefore, the same user can sign back into your app without a prompt, because they are already signed into Google and because the app still has access to all the previously-accepted scopes.

You could remove the previously-accepted scopes by calling disconnect(), but then the user will have to accept the same scopes again, which is probably not what you want.

Related