Automatic sign-in and sign-out  |  Authentication  |  Google for Developers (2024)

Chrome third-party cookie deprecation starts Q1 2024. Follow the migration guide to review potential changes and avoid negative impacts for user sign-in to your website.

  • Home
  • Products
  • Google Identity
  • Authentication
  • Sign In with Google for Web
Stay organized with collections Save and categorize content based on your preferences.

This page describes how to implement features related to how users sign in orsign out with Google One Tap.

Sign in users automatically

Google One Tap supports automatic sign-in, which provides a frictionless userexperience (UX) by removing the manual steps visitors must take when returningto your site. Users don't need to remember which Google Account they selectedduring their last visit, decreasing the chances of unnecessary duplicateaccounts being created on your platform.

Automatic sign-in is intended to complement our Sign in with Google buttonand One Tap dialogs. It is designed to be used across your entire site, withmanual sign-up or switching accounts occurring only after the user has firstsigned-out of your site.

For Automatic sign-in to occur the following conditions are required:

  • users must first be signed-in to their Google Account, and
  • previously granted consent to share their account profile with your app, and
  • when using FedCM, made only a single sign-in attempt in the last 10 minutes.One Tap is displayed when repeated sign-in attempts occur during this window.
  • when using FedCM, Chrome requires users to reconfirm that they want tosign in to the website with Google Account in each Chrome instance even if theuser approved the website prior to the FedCM rollout. This change may affectconversion rate on your existing site using One Tap. In Chrome M121 update,Auto Sign-in improvement mitigates conversion rate drop issue.

For pages where Automatic sign-in is enabled and if these conditions are metthe visitors ID token credential is automatically returned without any userinteraction. If these conditions are not met, and even if Automatic sign-in isenabled on the page, the user defaults to the One Tap flow for sign-in orconsent. If a user has multiple Google Accounts and visits your site they arerequired to first sign-in to a single Google Account and to have providedconsent for that account.

You may measure Automatic sign-in success rate using the auto value in theselect_by field of the returned credential object.

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

<div id="g_id_onload" data-client_id="YOUR_GOOGLE_CLIENT_ID" data-login_uri="https://your.domain/your_login_endpoint" data-auto_select="true"></div>

Sign out

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

Using FedCM

To improve user experience, there is a 10 minute quiet period between everyautomatic sign-in attempt. During this time period, One Tap prompt isdisplayed instead. Users need to explicitly click One Tap to sign in.

Without FedCM

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

<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 = () => { google.accounts.id.disableAutoSelect();}

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

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

If you don't want to load the client library on your post-login pages, usethese solutions to prevent a dead-loop UX after log out occurs:

  • On log out, redirect users to a page (say,https://example.com/logged_out) where One Tap is not displayed, orwhere auto sign-in is always disabled.
  • On log out, add a parameter to the URL. For example, logged_out=1.When rendering One Tap by JavaScript API, check that URL parameter anddisable auto sign-in when present.

Key user journeys

The automatic sign-in page.

Using FedCM

Automatic sign-in and sign-out | Authentication | Google for Developers (1)

Users can close the One Tap prompt by clicking the X button. Foraccessibility consideration, an ID token is shared with your websiteeven if users click the X button.

To improve user experience, there is a 10 minute quiet period between everyautomatic sign-in attempt. During this time period, One Tap prompt isdisplayed instead. Users need to explicitly click One Tap to sign in.

Without FedCM

Automatic sign-in and sign-out | Authentication | Google for Developers (2)

If users don't click the Cancel button within 5 seconds, an ID tokenis shared with your website.

When Sign-In is cancelled, based on the number of active Google sessions,either the account chooser page or the returning user page displays.

  • Multiple Google sessions

Automatic sign-in and sign-out | Authentication | Google for Developers (3)

  • Single Google Sessions

Automatic sign-in and sign-out | Authentication | Google for Developers (4)

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-05-01 UTC.

Automatic sign-in and sign-out  |  Authentication  |  Google for Developers (2024)

FAQs

Automatic sign-in and sign-out  |  Authentication  |  Google for Developers? ›

Automatic sign-in is intended to complement our Sign in with Google button and One Tap dialogs. It is designed to be used across your entire site, with manual sign-up or switching accounts occurring only after the user has first signed-out of your site.

What is automatic sign in? ›

Automatic sign-in is intended to complement our Sign in with Google button and One Tap dialogs. It is designed to be used across your entire site, with manual sign-up or switching accounts occurring only after the user has first signed-out of your site.

What is the automatic sign in for Google? ›

Important: To use Automatic Sign-in, you must already be signed in to your Google Account and have previously granted consent to share your profile with the third party for the purpose of signing in. If you haven't granted consent to the third party, the Google sign-in prompt appears.

Does Google automatically sign you out? ›

Whenever you sign in to your Google Account, you'll stay logged in until you select “sign out”. If you're using a shared or public computer, it's a good idea to use private browsing to protect your information. Once you're done browsing, close all the private windows and you'll be automatically signed out.

Is Google OAuth 2.0 free? ›

The API we'll use is Google OAuth 2.0 Playground. It's public, but it has rate limits on the requests you can make. This “free” API will work wonderfully for testing your application and understanding how OAuth works, but it isn't meant for production-level code.

What does automatic logout means? ›

Automatic Logout

You can configure the amount of time that Workflow remains active without any user activity before the user is logged out of the system. When automatic logout is enabled, Workflow logs out the current user after a specified time of inactivity and remains logged out if automatic login is disabled.

Why not to use automatic login? ›

The Issues With Auto-Login

Auto-login may save you time and energy, but it can also save thieves or hackers time and energy. If you have pretty much everything you use on an active basis set to auto-login, and if someone else gets access to your phone itself, they will have immediate access to everything you do.

How do I stop automatic sign-in? ›

Windows 10:
  1. Open Settings.
  2. Select "Accounts"
  3. Select "Sign-in Options" on the left-hand menu.
  4. Under "Require Sign-in," change the drop-down menu to "When PC wakes up from sleep"

How do I automatically login to a website? ›

How to automatically sign in to websites with Password Manager
  1. Open your web browser.
  2. Click the Password Manager icon on your browser.
  3. Go to the Password Manager Menu , then choose Settings.
  4. Click the Other tab.
  5. Put a check beside Always sign into websites without asking.
Mar 11, 2022

How to auto sign in in Chrome? ›

Manage auto sign-in

On your computer, open Chrome. Google Password Manager. On the left, select Settings. Turn Sign in automatically on or off.

Why is Google constantly asking me to sign in? ›

If Google keeps signing you out, here are some steps you can try: Make sure cookies are turned on. Some antivirus or related software may delete your cookies. If your cookies are turned on, clear your browser's cache.

What happens if I use Google without signing in? ›

Browsing without an account means your activity isn't saved to any Google account. It's that easy. However, if you're not in Incognito Mode, your search history, cache, and cookies are still saved on your device. Google does not collect as much personal information if you're signed out.

Why is a bad idea to use OAuth 2.0 for authentication? ›

Leaking authorization codes and access tokens. Perhaps the most infamous OAuth-based vulnerability is when the configuration of the OAuth service itself enables attackers to steal authorization codes or access tokens associated with other users' accounts.

Why use Google OAuth? ›

OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private. For example, an application can use OAuth 2.0 to obtain permission from users to store files in their Google Drives.

How much does a Google login cost? ›

Google Sign-in is a free service. To use Google sign-in you have to use Google's Firebase authentication service.

How do I get rid of automatic sign in? ›

How To Disable Automatic Login:
  1. Step 1: Press Win+R, enter “netplwiz“, which will open the “User Accounts” window. ...
  2. Step 2: On the “User Accounts” window, select the user account and check the option for “Users must enter a username and password to use this computer” and then click Apply.

What is the difference between single sign on and auto sign on? ›

Unlike SSO, auto login is a password-based authentication and can be used for applications that do not support single sign-on.

What is auto sign? ›

An auto signature is a personalized block of text, and often images, that is automatically added to the end of various digital documents, including emails, electronic contracts, PDFs, and other electronic files.

What is Apple automatic login? ›

Use automatic login: Choose a user, enter the password, then follow the onscreen instructions. Automatic login takes effect the next time you restart the Mac and whenever the Mac starts up, that user is automatically logged in. Turn off automatic login: Choose Off.

Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5360

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.