Skip to main content

Firebase Integration with SmythOS

Need to manage users for your application? Connect Firebase Authentication to SmythOS and empower your agents to handle user creation, sign-in, and data retrieval programmatically.

TL;DR

Securely link your Firebase project to SmythOS using your Web API Key. Then, use our suite of Firebase components to automate the entire user authentication lifecycle, from creating new users to fetching their data.

List of Firebase Components

Quickly compare Firebase Authentication components by what they do and their key I/O. Click any component name to jump directly to its detailed guide.

ComponentActionWhat it DoesInputsKey OutputsUse Case
Create UserWriteCreates a new user with an email and password.required email, passwordidToken, localIdHandling new user sign-ups.
Sign In With Email & PasswordAuthAuthenticates a user and returns an ID token.required email, passwordidToken, localIdLogging users into your application.
Get User DataReadRetrieves the profile information of an authenticated user.required idTokenusersFetching user details after they sign in.
INFO
Why Integrate Firebase with Your Agent?

Firebase provides a complete suite of tools for building applications, with Firebase Authentication being a cornerstone service. Integrating it with SmythOS allows you to build agents that can manage your app's user base.

  • Automate User Onboarding: Create agents that handle the entire sign-up process. When a new user fills out a form, an agent can automatically create their account in Firebase.
  • Backend for Frontend Operations: Build agents that act as a secure backend for your frontend application. An agent can take user credentials, sign them in using Firebase, and then perform actions on their behalf.
  • Personalized Experiences: Use agents to fetch data for a logged-in user to provide a personalized experience. For example, an agent could retrieve a user's name and past orders to customize a conversation.
  • Streamline User Management: Automate administrative tasks like updating user passwords or emails (by combining these components with other Firebase REST API calls in a generic API component).

Prerequisites

Before you begin, please ensure you have the following:

  • An active SmythOS account. (Sign up here).
  • A Google Firebase Project.
  • Email/Password Sign-In enabled in your Firebase Authentication settings.
  • Your Firebase project's Web API Key.

Getting Started With Firebase

The connection between SmythOS and Firebase Authentication is configured using your project's Web API Key.

Step 1: Get Your Firebase Web API Key

  1. Navigate to the Firebase Console and select your project.
  2. In the project sidebar, click the Settings gear and select Project settings.
  3. Under the General tab, scroll down to the "Your apps" card.
  4. If you don't have a web app, create one by clicking the </> icon.
  5. In your web app's configuration details, you will find the apiKey. Copy this value.

Step 2: Store Your API Key in SmythOS Vault

Your API Key is a sensitive credential. Use the SmythOS Vault to store it securely.

  1. In your SmythOS dashboard, navigate to the Vault.
  2. Create a new secret and paste your Firebase Web API Key as the value. Give it a memorable name, like firebase_web_api_key.
  3. For more details, see the Vault Documentation.

Step 3: Configure a Firebase Component

  1. In your SmythOS agent graph, drag and drop any Firebase component.
  2. Click the component to open its Settings panel.
  3. In the API Key field, select the secret you saved in the Vault (e.g., firebase_web_api_key).
  4. Your connection is now configured for that component.
Heads-up
You must add the API Key from the Vault to each Firebase component you use. This key identifies your Firebase project for each request.

Which Firebase Component Should I Use?

If you need to…WorkflowUse this ComponentWhy this one?
Register a new user for your appUser Sign-upCreate UserThis is the dedicated endpoint for creating a new account with email and password.
Log an existing user inUser Sign-inSign In With Email & PasswordThis component authenticates a user's credentials and returns a session idToken.
Get details for the current user (e.g., after they log in)Fetching ProfileGet User DataThis takes the idToken from a sign-in event to securely retrieve that user's information.

Component Details

This section provides detailed information for each Firebase component.

Create User

Creates a new user account in your Firebase project using an email and password.

INFO
This component requires a Web API Key for authentication, as detailed in the Getting Started section.

Inputs

FieldTypeRequiredNotes
emailstringYesThe user's email address. Must be a valid email format.
passwordstringYesThe user's password. Must be at least six characters long.

Outputs

FieldTypeDescription
idTokenstringA Firebase ID token for the newly created user's session.
localIdstringThe unique user ID (UID) assigned to the new user.
ResponseobjectThe full, raw JSON response from the Firebase Auth API.
HeadersobjectThe HTTP headers from the API response.
Use Case

An agent powers a "Sign Up" form. It takes the submitted email and password, passes them to this component, and upon success, uses the localId to create a corresponding user profile in a separate database.

{
"component": "firebase.createUser",
"email": "new.user@example.com",
"password": "strongPassword123"
}
Security

Always handle passwords securely. This component should be called from a trusted server-side environment like a SmythOS agent, not directly from a client-side browser where the password could be intercepted.

Sign In With Email & Password

Signs in an existing user with their email and password and returns an ID token for their session. (Formerly "ID Token").

INFO
This component requires a Web API Key for authentication, as detailed in the Getting Started section.

Inputs

FieldTypeRequiredNotes
emailstringYesThe email address of the existing user.
passwordstringYesThe password for the user's account.

Outputs

FieldTypeDescription
idTokenstringA Firebase ID token for the authenticated user's session. This is required for other authenticated requests.
localIdstringThe unique user ID (UID) of the signed-in user.
ResponseobjectThe full, raw JSON response from the Firebase Auth API.
HeadersobjectThe HTTP headers from the API response.
Use Case

This component is the core of a login workflow. After a user signs in, the agent receives the idToken and passes it to the "Get User Data" component to fetch their profile and personalize the app experience.

{
"component": "firebase.idToken",
"email": "existing.user@example.com",
"password": "userPassword123"
}
Token Expiration

The idToken returned by this component is short-lived (typically one hour). For long sessions, you will need to use the refreshToken (found in the raw Response) to get a new ID token.

Get User Data

Retrieves the profile information for an authenticated user, using their session ID token.

INFO
This component requires a Web API Key for authentication, as detailed in the Getting Started section.

Inputs

FieldTypeRequiredNotes
idTokenstringYesThe Firebase ID token obtained from a successful sign-in.

Outputs

FieldTypeDescription
usersarrayAn array containing a single user object with their profile information (UID, email, creation date, etc.).
ResponseobjectThe full, raw JSON response from the Firebase Auth API.
HeadersobjectThe HTTP headers from the API response.
Use Case

After a user logs in successfully using the "Sign In" component, the agent immediately calls this component with the resulting idToken to retrieve the user's display name and greet them personally.

{
"component": "firebase.getUserData",
"idToken": "id-token-from-previous-step"
}
Authentication Required

This component will fail if the idToken is missing, invalid, or expired. It is a secure way to fetch data only for the currently authenticated user.

Best Practices & Advanced Tips

  • Secure Your API Key: Always store your Firebase Web API key in the SmythOS Vault. While it is a public key, keeping it in the Vault makes management easier.
  • Understand the Auth Flow: The typical flow is Create User for new users, followed by Sign In to get an idToken, and then Get User Data using that token. For returning users, the flow starts with Sign In.
  • Handle Tokens Securely: The idToken proves a user is signed in. Never expose it to untrusted environments. It should be managed within your agent's workflow to make secure requests.
  • Use Firebase Security Rules: While this integration manages users, remember to configure Firebase Security Rules for services like Firestore and Cloud Storage to control what data each authenticated user can access.

Troubleshooting Common Issues

  • Error: EMAIL_EXISTS

    • Cause: Attempting to create a user with an email address that is already registered in your Firebase project.
    • Solution: This is expected behavior. Your agent's logic should handle this by informing the user that the email is already in use, perhaps suggesting they sign in instead.
  • Error: INVALID_PASSWORD or EMAIL_NOT_FOUND

    • Cause: The email/password combination provided to the "Sign In" component is incorrect.
    • Solution: This is a standard failed login attempt. Your agent should return a generic "Invalid credentials" message to the user.
  • Error: TOKEN_EXPIRED

    • Cause: The idToken used in the "Get User Data" component has expired (they typically last for one hour).
    • Solution: Your application needs a mechanism to refresh the ID token using the refresh token provided upon sign-in. This is a more advanced flow that may require calling the Firebase token refresh endpoint.
  • Error: API_KEY_NOT_VALID

    • Cause: The Web API Key configured in the component's settings is incorrect.
    • Solution: Go to your Firebase Project Settings, copy the correct apiKey, and update the secret in your SmythOS Vault.

What's Next?

You are now ready to build applications with secure user management using the SmythOS Firebase Integration!

Consider these ideas:

  • Build an Agent That...

    • Manages a complete user lifecycle. A user signs up via a form, the agent calls Create User, then logs the new localId into a separate database (like Firestore or a SQL database) to store additional profile information.
    • Acts as a backend for a simple web app. The frontend collects login details, sends them to the agent, which uses Sign In to authenticate, and then uses the idToken to securely fetch and return user-specific data.
    • Connects to other services. After a user signs up with Firebase, the agent could also create a corresponding customer profile in a CRM like HubSpot.
  • Explore Other Integrations:

    • Combine Firebase Auth with a database integration like Firestore (via the OpenAPI component) or a SQL database to store and retrieve data associated with a user's localId.
    • After a new user is created, trigger a welcome Gmail to be sent to their registered email address.