Warning: This data is provided under the Google User Data Policy. Please review and comply with the policy. Failure to do so may result in project suspension or account suspension.

Automatic sign in and sign out

This page describes how to implement features related to users signing in or out with One Tap.

Sign in users automatically

Google One Tap supports automatic sign-in. If there's only one Google session has approved your website, the ID token for that session will be returned automatically without any user interaction.

Automatic sign-in makes the returning user sign-in UX more smooth. Also users don't need to remember which Google account has been selected before for your website. Thus, it's less likely to create unnecessary duplicate accounts on your websites due to different accounts being selected.

To enable automatic sign-in, add data-auto_select="true" to your code, such as in the following snippet:

<div id="g_id_onload"

Sign out

When a user signs out of your website, they can be directed to a page where a Google One Tap prompt is automatically displayed. For this setup, auto-selection must be prohibited. Otherwise, the user is automatically signed in again, which leads to a dead-loop UX.

To prohibit auto-selection after a user signs out, add the class name g_id_signout to all of your logout links and buttons. See the following code snippet:

<div class="g_id_signout">Sign Out</div>

The following JavaScript code snippet can also be used for sign out:

  const button = document.getElementById(‘signout_button’);
    button.onclick = () => {

Consequently, the signed-out status is recorded through a cookie in your domain so that the dead-loop UX is avoided.

The sign-out status is stored into the g_state cookie in your domain. If you have a service that monitors all of the cookies used in your domain, you need to notify them of this cookie.