Hello! This is a demo for Google One Tap Sign In

Made by leeminkan. Check the source code here!

The One Tap Popup will appear on the top-right of the screen every 2s!

After choosing an google account, we can receive the response after sign in successfully

null

We can use this response.credential to fetch the user account information, such as email, picture... in our server

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import { OAuth2Client } from "google-auth-library"; const googleAuthClient = new OAuth2Client(process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID); const token = response?.credential; const ticket = await googleAuthClient.verifyIdToken({ idToken: token, audience: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, }); const payload = ticket.getPayload(); if (!payload) { throw new Error("Cannot extract payload from sign-in token"); } const { email, sub, given_name, family_name, email_verified, picture: image } = payload;

If there are any issues, the popup does not appear. Please check this log