Back

Firebase Auth API Essential Guide

Aug 9, 20246 minute read

What type of API does Firebase Auth provide?

Firebase Auth provides a REST API for authentication operations. The key points about the Firebase Auth REST API are:

  1. Type of API: Firebase Auth uses a REST API.

  2. Authentication: The Firebase Auth REST API does not require authentication itself. It is a public API designed to allow users to authenticate without additional permissions.

  3. Key features:

    • Allows operations like sign up, sign in, password reset, etc.
    • Uses standard HTTP methods like GET, POST, etc.
    • Responses are in JSON format.
  4. Endpoint: The base URL for the Firebase Auth REST API is: https://identitytoolkit.googleapis.com/v1/accounts.

  5. Security: While the API itself doesn't require authentication, you control the types of auth allowed in your app using the Firebase console.

  6. Usage: The API is used by Firebase SDKs and can also be called directly from applications.

  7. Documentation: Full documentation is available at https://firebase.google.com/docs/reference/rest/auth.

  8. Best practices:

    • Use HTTPS for all API calls
    • Validate responses on the client-side
    • Follow Firebase security rules for data access

In summary, Firebase Auth provides a REST API that doesn't require authentication itself, as it's designed to allow users to authenticate. The security is managed through your Firebase project settings rather than at the API level.

Does the Firebase Auth API have webhooks?

Does Firebase Auth have official webhooks?

No, Firebase Auth does not have native webhook support like some other services. However, you can replicate webhook-like functionality using Firebase Cloud Functions.

How to implement webhook-like functionality for Firebase Auth events

While not official webhooks, you can use Firebase Cloud Functions to respond to auth events and trigger actions, similar to webhooks:

  1. Use Cloud Functions event handlers like functions.auth.user().onCreate() to trigger on auth events.
  2. Within the Cloud Function, you can make HTTP requests to your own endpoints to notify external systems.
  3. This allows you to respond to events like user creation, deletion, and first-time sign ins with providers.

Types of auth events you can subscribe to

Some key auth events you can respond to include:

  • User creation (onCreate)
  • User deletion (onDelete)
  • User sign in (for first-time sign ins with providers)

Key considerations

  • This approach requires using Firebase Cloud Functions as an intermediary.
  • You'll need to implement the HTTP requests to your endpoints within the Cloud Functions.
  • While not as direct as native webhooks, it provides similar capabilities for responding to auth events.

Firebase Auth API

Firebase does provide APIs for various services, including Authentication:

  • Firebase Authentication API for user auth and management
  • APIs for other Firebase services like Realtime Database, Firestore, Cloud Messaging, etc.

So while there aren't native webhooks, the combination of Cloud Functions and APIs allows you to implement webhook-like functionality for Firebase Auth events.

Rate Limits and other limitations

Here are the key points about API rate limits for Firebase Auth:

Identity Toolkit API Limits

  • Operations per service account: 500 requests/second
  • Operations per project: 1000 requests/second, 10 million requests/day
  • Account uploads per project: 3600 uploads/minute
  • Account downloads per project: 21,000 requests/minute
  • UserInfo queries per project: 900 requests/minute
  • Configuration updates per project: 300 requests/minute
  • Bulk delete accounts per project: 3000 requests/minute
  • Custom token sign-ins per project: 45,000 sign-ins/minute
  • createAuthURI calls per IP address: 120 requests/hour
  • Blocking function invocations per project: 2000 requests/minute
  • GetAccountInfo per project: 500,000 requests/minute

Phone Number Sign-In Limits

  • User sign-ins: 1600/minute
  • Verification requests: 150 requests/IP address/hour

Other Limits

  • Token exchange per project: 18,000 exchanges/minute
  • The API limits apply to both the Client SDK and Admin SDK
  • Limits apply to operations like creating users, signing in users, editing/deleting users, etc.
  • Some internal quotas (e.g. for token refreshing) are not publicly disclosed

Key Considerations

  • The 1000 requests/second per project limit applies to the total of all Auth API requests
  • To avoid unnecessary token refreshes, set forceRefresh to false when possible
  • If hitting quota errors, contact Firebase support
  • Some quotas can be increased by contacting Firebase support in advance

The rate limits are designed to prevent abuse while allowing normal usage. Most applications should not hit these limits under normal circumstances. If you are consistently hitting limits, you may need to optimize your usage or contact Firebase support to discuss your use case.

Latest API Version

Based on the search results provided, I cannot determine the most recent version of the Firebase Auth API with certainty. The search results contain release notes for various Firebase SDKs and components, but they do not provide specific version numbers for the Firebase Auth API. However, I can provide some key points about Firebase Auth updates:

Key points:

  1. Firebase Authentication has received regular updates as part of the overall Firebase SDK releases.

  2. The most recent Firebase CLI version mentioned is v13.14.0, which includes support for Firebase alerts events in the Cloud Functions emulator.

  3. The Firebase JavaScript SDK has had multiple versions released with updates to Authentication, including versions 3.5.3, 3.8.0, 4.1.0, 4.1.5, and 4.6.0.

  4. The Firebase Android SDK has also received updates to the Authentication component, but specific version numbers are not provided in the search results.

  5. The latest update to Firebase mentioned in the search results (as of September 1, 2022) included changes to Firebase Authentication, among other components.

Best practices:

  1. To find the most recent version of the Firebase Auth API, it's recommended to check the official Firebase documentation or release notes, which are not fully represented in these search results.

  2. Always use the latest stable version of the Firebase SDK to ensure you have the most up-to-date features and security improvements for Authentication.

  3. When implementing Firebase Authentication, refer to the official documentation for the most current best practices and implementation guidelines.

  4. Keep your Firebase CLI and SDKs updated regularly to benefit from the latest improvements and bug fixes.

While I cannot provide the exact version number of the most recent Firebase Auth API based on these search results, it's clear that Firebase Authentication is actively maintained and updated as part of the overall Firebase ecosystem.

How to get a Firebase Auth developer account and API Keys?

Here's the rewritten section on how to get a Firebase Auth developer account and API keys:

Key Steps

  1. Create a Google account if you don't already have one.

  2. Go to the Firebase Console (console.firebase.google.com) and sign in with your Google account.

  3. Click "Create a project" or "Add project" to create a new Firebase project.

  4. Enable Firebase Authentication for your project:

    • In the Firebase Console, go to "Authentication" in the left sidebar
    • Click "Get Started"
    • Enable the sign-in methods you want to use (email/password, phone, Google, etc.)
  5. Set up your development environment:

    • Install the Firebase CLI: npm install -g firebase-tools
    • Login to Firebase: firebase login
    • Initialize your project: firebase init
  6. Add the Firebase SDK to your app:

    • Web: Add the Firebase JS SDK
    • iOS: Add the Firebase iOS SDK
    • Android: Add the Firebase Android SDK
  7. Implement authentication in your app using the Firebase Auth SDK.

  8. To create an API integration, you'll need to:

    • Generate a private key file for your service account
    • Use the Firebase Admin SDK in your backend to verify ID tokens

What can you do with the Firebase Auth API?

Here's a list of data models you can interact with using the Firebase Auth API, along with bullet points describing what is possible for each:

User

  • Create new user accounts
  • Sign in existing users
  • Sign out users
  • Get the currently authenticated user
  • Update user profile information (display name, photo URL)
  • Update user email address
  • Update user password
  • Send password reset emails
  • Send email verification
  • Delete user accounts
  • Link multiple auth providers to a single account
  • Get user metadata (creation time, last sign-in time)
  • Set custom user claims for role-based access control

User Profile

  • Get and set user display name
  • Get and set user photo URL
  • Get user email address
  • Get user phone number
  • Get user provider-specific profile information

Authentication Providers

  • Configure and manage various authentication providers:
    • Email/Password
    • Google
    • Facebook
    • Twitter
    • GitHub
    • Apple
    • Microsoft
    • Yahoo
    • Phone number (SMS)
    • Anonymous
    • Custom auth systems

Multi-Factor Authentication (MFA)

  • Enable/disable multi-factor authentication for users
  • Enroll additional factors (e.g., phone numbers for SMS verification)
  • Verify second factors during sign-in
  • Unenroll factors

User Sessions

  • Get user ID tokens
  • Verify ID tokens
  • Revoke user sessions
  • Set session persistence (local, session, or none)

Security Rules

  • Define and manage security rules for Firestore and Realtime Database based on user authentication status and custom claims

Email Templates

  • Customize email templates for:
    • Password reset
    • Email verification
    • Email change confirmation

OAuth Scopes

  • Manage OAuth scopes for social providers to request additional user information

Auth State

  • Listen for changes in authentication state
  • Get current auth state

User Claims

  • Set and manage custom claims for users
  • Use claims for role-based access control in security rules and server-side logic

Auth Emulator

  • Use the Firebase Auth Emulator for local development and testing

These data models and interactions cover the main functionalities provided by the Firebase Auth API, allowing developers to implement comprehensive authentication and user management systems in their applications.