Google Sign-In
Complete guide to enabling Google authentication in your Firebase project.
Google Sign-In is one of the most popular authentication methods for web applications. It allows users to sign in with their existing Google account, providing a seamless and trusted experience.
This guide summarizes the key steps. For complete details, see the Firebase Google Sign-In documentation.
- Open Firebase Console
Go to console.firebase.google.com and select your project.
- Navigate to Authentication
In the left sidebar, click Build → Authentication.
- Go to Sign-in Method
Click the Sign-in method tab at the top.
- Find Google Provider
In the Sign-in providers list, find Google.
- Click to Configure
Click on Google to open the configuration panel.
- Enable the Provider
Toggle the switch to enable Google as a sign-in method.
- Set Support Email
Enter a support email address. This is shown to users on the consent screen.
- Save
Click Save to enable the provider.
For production apps, you may need to configure the OAuth consent screen in Google Cloud Console:
- Open GCP Console
Go to OAuth consent screen in GCP Console.
- Configure App Information
Fill in the app name, user support email, and developer contact information.
- Add Authorized Domains
Add your Vercel deployment domains (e.g.,
*.vercel.appand any custom domains).
Make sure to add all domains where your app will be accessed, including localhost for development, Vercel preview URLs, and any custom production domains.
Once enabled, you can implement Google Sign-In in your app using the Firebase Auth SDK:
import { getAuth, signInWithPopup, GoogleAuthProvider } from 'firebase/auth';
const auth = getAuth();
const provider = new GoogleAuthProvider();
// Optional: Add scopes for additional permissions
provider.addScope('profile');
provider.addScope('email');
// Sign in with popup
async function signInWithGoogle() {
try {
const result = await signInWithPopup(auth, provider);
const user = result.user;
console.log('Signed in as:', user.displayName);
} catch (error) {
console.error('Sign-in error:', error);
}
}Alternative: Use redirect instead of popup (better for mobile):
import { signInWithRedirect, getRedirectResult } from 'firebase/auth';
// Trigger redirect
await signInWithRedirect(auth, provider);
// Handle result (call this on page load)
const result = await getRedirectResult(auth);
if (result) {
const user = result.user;
// User is signed in
}To test Google Sign-In:
- Run Your App Locally
Start your development server and navigate to the sign-in page.
- Click Sign In with Google
The Google sign-in popup (or redirect) should appear.
- Select an Account
Choose a Google account to sign in with.
- Verify in Firebase
Check the Firebase Console → Authentication → Users to see the signed-in user.
Common issues and solutions:
- Popup Blocked – Ensure the sign-in is triggered by a user action (button click). Browsers block popups not initiated by user interaction.
- Domain Not Authorized – Add your domain to the authorized domains list in Firebase Console → Authentication → Settings.
- OAuth Error – Check that the OAuth consent screen is properly configured in GCP Console.
- CORS Errors – Ensure your Firebase config is correct and matches the project.