\n```\n\n## 3) Choose your sign-in flow\n\n### Option A: One Tap / button flow with a token response\nGoogle handles the UI and returns an ID token to your frontend.\n\nExample:\n\n```html\n
\n
\n\n
\n\n\n```\n\n### Option B: OAuth redirect flow\nIf you need server-side authorization access, use the standard OAuth flow with redirects.\n\n## 4) Verify the token on your backend\nDo **not** trust the frontend alone. Send the ID token to your server and verify it using Google libraries.\n\nExample in Node.js:\n\n```js\nimport { OAuth2Client } from \"google-auth-library\";\n\nconst client = new OAuth2Client(process.env.GOOGLE_CLIENT_ID);\n\napp.post(\"/auth/google\", async (req, res) => {\n const { id_token } = req.body;\n\n const ticket = await client.verifyIdToken({\n idToken: id_token,\n audience: process.env.GOOGLE_CLIENT_ID,\n });\n\n const payload = ticket.getPayload();\n const userId = payload.sub;\n const email = payload.email;\n\n // Create session / JWT for your app here\n res.json({ success: true, userId, email });\n});\n```\n\n## 5) Create your app session\nAfter verifying Google’s token, create your own:\n- session cookie, or\n- JWT for your app\n\nThis is what your app uses after login.\n\n## 6) Important security notes\n- Always verify tokens on the backend\n- Restrict by your **Google client ID**\n- Use HTTPS in production\n- Store secrets safely\n- If you request Google API access beyond sign-in, use the correct OAuth scopes and consent setup\n\n## 7) If you use a framework\nCommon integrations exist for:\n- **React**\n- **Next.js**\n- **Vue**\n- **Angular**\n- **Firebase Auth** (simpler if you want Google sign-in plus auth/session handling)\n\nIf you want, I can give you a **copy-paste example for React, Next.js, or plain HTML/Node.js**."}}}

Prompt

How do I add Sign in with Google to my web app?

Technology / Identity & Access1 observationLast seen Oct 6, 2026

Latest observation

Oct 6, 2026OpenAI APIWeb search: off

To add Sign in with Google to a web app, the easiest modern approach is to use Google Identity Services (GIS).

1) Create a Google Cloud project

  1. Go to the Google Cloud Console
  2. Create a new project
  3. Set up the OAuth consent screen
  4. Create OAuth 2.0 Client ID credentials
    • Application type: Web application
    • Add your authorized JavaScript origins
    • Add your authorized redirect URIs if you use redirect flow

2) Add the Google Identity Services script

Include this in your page:

<script src="https://accounts.google.com/gsi/client" async defer></script>

3) Choose your sign-in flow

Option A: One Tap / button flow with a token response

Google handles the UI and returns an ID token to your frontend.

Example:

<div id="g_id_onload"
     data-client_id="YOUR_GOOGLE_CLIENT_ID"
     data-callback="handleCredentialResponse">
</div>

<div class="g_id_signin" data-type="standard"></div>

<script>
  function handleCredentialResponse(response) {
    // response.credential is the ID token (JWT)
    console.log("ID token:", response.credential);

    // Send token to your backend for verification
    fetch("/auth/google", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ id_token: response.credential })
    });
  }
</script>

Option B: OAuth redirect flow

If you need server-side authorization access, use the standard OAuth flow with redirects.

4) Verify the token on your backend

Do not trust the frontend alone. Send the ID token to your server and verify it using Google libraries.

Example in Node.js:

import { OAuth2Client } from "google-auth-library";

const client = new OAuth2Client(process.env.GOOGLE_CLIENT_ID);

app.post("/auth/google", async (req, res) => {
  const { id_token } = req.body;

  const ticket = await client.verifyIdToken({
    idToken: id_token,
    audience: process.env.GOOGLE_CLIENT_ID,
  });

  const payload = ticket.getPayload();
  const userId = payload.sub;
  const email = payload.email;

  // Create session / JWT for your app here
  res.json({ success: true, userId, email });
});

5) Create your app session

After verifying Google’s token, create your own:

  • session cookie, or
  • JWT for your app

This is what your app uses after login.

6) Important security notes

  • Always verify tokens on the backend
  • Restrict by your Google client ID
  • Use HTTPS in production
  • Store secrets safely
  • If you request Google API access beyond sign-in, use the correct OAuth scopes and consent setup

7) If you use a framework

Common integrations exist for:

  • React
  • Next.js
  • Vue
  • Angular
  • Firebase Auth (simpler if you want Google sign-in plus auth/session handling)

If you want, I can give you a copy-paste example for React, Next.js, or plain HTML/Node.js.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as Circuit. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.