0
0
Firebasecloud~5 mins

Google sign-in in Firebase - Commands & Configuration

Choose your learning style9 modes available
Introduction
Google sign-in lets users log into your app using their Google account. It solves the problem of creating and managing separate usernames and passwords by using a trusted Google login.
When you want users to quickly sign in without creating a new account.
When you want to improve security by using Google's authentication system.
When you want to reduce password management and reset requests.
When you want to access basic user profile info like name and email easily.
When you want to support single sign-on across multiple apps using Google accounts.
Config File - firebase.json
firebase.json
{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/**",
        "destination": "/index.html"
      }
    ]
  }
}

This file configures Firebase hosting.

hosting.public: folder with your app files.

Commands
Log in to Firebase CLI with your Google account to manage your Firebase projects.
Terminal
firebase login
Expected OutputExpected
✔ Success! Logged in as your-email@gmail.com
Initialize Firebase Authentication in your project to enable sign-in methods like Google.
Terminal
firebase init auth
Expected OutputExpected
=== Authentication Setup === ✔ Firebase Authentication enabled ✔ Google sign-in provider enabled Firebase Authentication has been set up in your project.
Deploy the authentication configuration to Firebase so Google sign-in becomes active.
Terminal
firebase deploy --only auth
Expected OutputExpected
=== Deploying to 'your-project-id'... ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/your-project-id/authentication/providers
--only - Deploy only the specified Firebase feature, here 'auth' for authentication.
List all enabled sign-in methods to verify Google sign-in is active.
Terminal
firebase auth:sign-in-methods:list
Expected OutputExpected
Enabled sign-in methods: - Google - Email/Password
Key Concept

If you remember nothing else from this pattern, remember: enabling Google sign-in in Firebase lets users log in easily using their existing Google accounts without managing new passwords.

Common Mistakes
Not enabling Google sign-in provider in Firebase console or config.
Users cannot log in with Google if the provider is not enabled.
Always enable Google sign-in in Firebase Authentication settings before deploying.
Forgetting to deploy authentication changes after enabling Google sign-in.
Changes stay local and do not affect the live app.
Run 'firebase deploy --only auth' to apply authentication updates.
Using incorrect OAuth client IDs or not configuring OAuth consent screen in Google Cloud Console.
Google sign-in will fail due to invalid credentials or permissions.
Set up OAuth client IDs and consent screen properly in Google Cloud Console linked to your Firebase project.
Summary
Use 'firebase login' to authenticate your CLI with Firebase.
Run 'firebase init auth' to enable authentication and Google sign-in.
Deploy changes with 'firebase deploy --only auth' to activate Google sign-in.
Verify enabled sign-in methods with 'firebase auth:sign-in-methods:list'.