0
0
Firebasecloud~5 mins

Authentication providers overview in Firebase - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you build an app, you need a way to know who is using it. Authentication providers help you let users sign in easily and safely using different methods like email, phone, or social accounts.
When you want users to sign in with their Google account without creating a new password.
When you want to allow users to sign in using their phone number with a verification code.
When you want to let users create accounts using their email and password.
When you want to support sign-in with Facebook or Twitter for easier access.
When you want to manage user identity securely without building your own system.
Config File - firebase.json
firebase.json
{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
  },
  "auth": {
    "providers": [
      "google.com",
      "password",
      "phone",
      "facebook.com",
      "twitter.com"
    ]
  }
}

This file configures Firebase hosting and lists the authentication providers enabled for your app.

hosting.public points to your app's public files.

auth.providers lists the sign-in methods your app supports, like Google, email/password, phone, Facebook, and Twitter.

Commands
Log in to your Firebase account to manage your projects and authentication settings.
Terminal
firebase login
Expected OutputExpected
✔ Success! Logged in as user@example.com
Initialize Firebase Authentication in your project to enable sign-in methods.
Terminal
firebase init auth
Expected OutputExpected
✔ Firebase Authentication setup complete. ✔ Enabled providers: Google, Email/Password, Phone, Facebook, Twitter
Deploy your authentication configuration to Firebase so users can start signing in.
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/overview
--only - Deploy only the specified Firebase feature, here 'auth' for authentication.
List all users currently registered in your Firebase Authentication system.
Terminal
firebase auth:list
Expected OutputExpected
Users: - uid: abc123, email: user1@example.com, provider: password - uid: def456, email: user2@gmail.com, provider: google.com
Key Concept

If you remember nothing else from this pattern, remember: authentication providers let users sign in easily and securely using familiar accounts or methods without building your own system.

Common Mistakes
Not enabling the desired authentication providers in the Firebase console or config file.
Users cannot sign in with those methods if they are not enabled, causing login failures.
Always enable and configure each authentication provider you want to support before deploying.
Deploying the app without deploying the authentication configuration.
Changes to sign-in methods won't take effect, so users may not be able to log in as expected.
Run 'firebase deploy --only auth' after updating authentication settings.
Using phone authentication without setting up the required SMS verification in Firebase.
Phone sign-in will fail because Firebase cannot send verification codes.
Configure phone authentication properly in Firebase console and test SMS delivery.
Summary
Use 'firebase init auth' to set up authentication providers in your Firebase project.
Enable desired sign-in methods like Google, email/password, phone, Facebook, and Twitter in your config.
Deploy authentication settings with 'firebase deploy --only auth' to make them active.
Use 'firebase auth:list' to see registered users and verify authentication is working.