How Google One Tap works
You open example.com while signed in to Google and tap Continue as Alex. Google hands the site a sealed letter about you, and your server checks the seal before it signs you in.
Your page asks, and the browser draws the card
Your page loads Google's script and asks for an introduction. It draws nothing itself. The browser shows the card, with the Google account it already knows.
You call google.accounts.id.initialize() with your client ID, then prompt(). With FedCM, the browser puts the card on top of the page and sets its size and place. The old use_fedcm_for_prompt flag is now ignored. The card shows only on HTTPS, and only when the browser has an active Google session.
<script src="https://accounts.google.com/gsi/client" async></script>
<script>
window.onload = () => {
google.accounts.id.initialize({ client_id: "YOUR_CLIENT_ID",
callback: (r) => sendToServer(r.credential) });
google.accounts.id.prompt();
};
</script>
One tap, and Google writes a sealed letter for this site
You tap Continue. Google writes a short letter: who wrote it, who it is for, and who you are. Then it seals the letter, so nobody can change a word.
The letter is an ID token, a JWT signed by Google. iss names the writer. aud holds your client ID, so a letter written for another site fails your check.
Your page passes the letter to your server, still sealed
Your page does not open the letter or trust it. It sends the whole letter to your server, and the server does the checking.
The token arrives as credential. Pick one of two ways to deliver it. You cannot set both.
callback · your JavaScript
Your function gets a CredentialResponse. Send its credential to your server, for example with fetch.
login_uri · a form post
Your login endpoint gets a POST with credential and g_csrf_token. Reject it unless that token matches the cookie of the same name.
Your server checks the seal before it reads a word
Anyone can write "from Google" on a letter. Your server compares the seal with Google's public keys. Then it reads the addressee, the writer and the use-by date.
The keys live at https://www.googleapis.com/oauth2/v3/certs and rotate, so cache them only as long as Cache-Control says. Accept the token only when aud is your client ID, iss is accounts.google.com or https://accounts.google.com, and exp has not passed.
from google.oauth2 import id_token
from google.auth.transport import requests
# checks the seal, aud, iss and exp; raises if one fails
info = id_token.verify_oauth2_token(
credential, requests.Request(), CLIENT_ID)
user_id = info["sub"]
Always pass your client ID. Without it, the library skips the aud check.
Reading the letter is not checking it.
File the person under sub, never under the email
Every letter carries a member number. People change their email. The member number stays with the Google Account for good.
Google says sub is unique among all Google Accounts and never reused. The email claim can change over time. Use the email only to find an account that already exists, and only when email_verified is true.
Keyed by email
- Alex changes email.
- The next sign-in makes a second, empty account.
Keyed by sub
- Alex changes email.
- Both letters open the same account.
The email is a label. The sub is the person.
Before you rely on it
- catchClose the card a few times while you test, and it stops showing. Without FedCM, each close in a row pauses it longer: 2 hours, 1 day, 1 week, then 4 weeks. With FedCM, the browser sets the pause. In Chrome, reset it from the lock icon in the address bar with Reset Permission, and keep a Sign in with Google button for when the card does not show.
- ask nextCan it sign people in with no tap at all? Yes. With
auto_select: true, a returning user who approved your site before gets a token with no tap. On sign-out, callgoogle.accounts.id.disableAutoSelect(), or they land straight back in. - ask nextWhat do Safari and Firefox users see? Google calls them ITP browsers, with Chrome on iOS, and the normal card does not work there. Set
itp_support: truefor an upgraded flow there. - ask nextCan I call Google APIs with this token? No. This sign-in API returns only ID tokens. Reading someone's Drive or Calendar needs an access token from Google's separate authorization API.
- simplifiedOne browser and one Google account. The account chooser, the first-time consent screen and the pop-up fallbacks are left out.
- sourcesGoogle Identity docs: overview, client library, display One Tap, prompt UX and cooldown, FedCM migration, automatic sign-in, verify the ID token, JavaScript reference and OpenID Connect claims; the google-auth source for
verify_oauth2_token. - not verifiedWhether
disableAutoSelect()still applies with FedCM: Google's sign-out guide lists it under "Without FedCM". Google also does not say since when every Chrome draws the card through FedCM.