sign-in-with-google-web

Implement secure Sign In With Google using Google Identity Services across web architectures.

23.7k|2.0k|Updated Mar 31, 2026
Ready to run
npx skills add https://github.com/google/skills --skill sign-in-with-google-web-google
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: sign-in-with-google-web
Source: https://github.com/google/skills/tree/main/skills/identity/sign-in-with-google-web
Command: npx skills add https://github.com/google/skills --skill sign-in-with-google-web-google

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires google-auth, cryptography, and includes references (resource) components.

What problem does it solve? Integrating Google authentication securely requires handling OAuth 2.0 flows, JWT verification, token management, and browser security policies correctly. This Skill eliminates the complexity of implementing Sign In With Google safely across different application architectures, from backend-for-frontend patterns to client-only SPAs. ## Core Features & Use Cases - Secure Authentication Patterns: Implements IETF-compliant architectures (Backend For Frontend, Token-Mediating Backend, Browser-Based OAuth) with defensive coding against XSS and replay attacks. - Token Verification & Session Management: Server-side cryptographic JWT validation against Google's public keys, nonce replay protection, and secure HttpOnly cookie issuance. - Cross-Domain & Embedded Contexts: Handles One Tap in iframes, FedCM integration, Content Security Policy (CSP), Cross-Origin Opener Policy (COOP), and Permissions Policy headers. - Use Case: You are building a SaaS application and need to let users sign in with their Google account. This Skill provides complete implementation recipes for FastAPI backends, React frontends, and offline PWAs—all hardened against token theft and CSRF attacks. ## Quick Start Implement Sign In With Google using the Backend For Frontend pattern: add the GIS script to your HTML, capture the ID token in a JavaScript callback, POST it to your FastAPI endpoint which verifies the JWT cryptographically and issues an HttpOnly session cookie.

Frequently Asked Questions about sign-in-with-google-web

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I verify Google ID tokens server-side in Python?▼

Use google.oauth2.id_token.verify_oauth2_token() to cryptographically validate the JWT signature against Google's public JWKs, then check audience (aud), expiration (exp), and nonce claims. This must happen server-side before issuing any session token.

What is the most secure Sign In With Google architecture?▼

Backend For Frontend (BFF) pattern is the gold standard: the browser captures the ID token and immediately sends it to your backend via HTTPS POST. The backend verifies it cryptographically, validates nonce/audience claims, and issues an HttpOnly session cookie. ID tokens never remain in browser JavaScript.

How do I prevent XSS attacks when storing authentication tokens?▼

Use HttpOnly; Secure; SameSite=Lax server-side session cookies exclusively—never store raw JWTs in localStorage or sessionStorage. For offline PWAs, encrypt ID tokens with non-extractable WebCrypto AES-GCM keys before writing to IndexedDB.

Does Sign In With Google work inside iframes?▼

Yes, with the Intermediate Iframe API (gsi/intermediate). Requires Permissions Policy allow="identity-credentials-get" on the container iframe and strict origin validation in postMessage listeners to prevent credential exfiltration.

What is nonce validation and why does it matter?▼

A nonce is a cryptographic random value generated client-side and passed to Google during authentication. The ID token includes this nonce value. Server-side verification ensures the token was issued for this specific authentication request, blocking token replay attacks and binding tokens to session context.

How do I handle user sign-out correctly with Google One Tap?▼

Call google.accounts.id.disableAutoSelect() before clearing the session. Omitting this causes automatic re-login loops because One Tap re-authenticates immediately on the next page visit after logout.