Skip to content

Authentication Examples

This section demonstrates the most common and practical usage patterns of Firebase Authentication in Unreal Engine projects.

Firebase Authentication is used to create and manage a user identity that can be shared across other Firebase services such as Realtime Database, Firestore, and Cloud Storage.

All examples below are shown using Blueprint nodes. Firebase is assumed to be already initialized.


Initializing Authentication

Before using any authentication features, the Authentication module must be initialized.

Initialization should be performed once, typically during game startup, after Firebase itself has been successfully initialized.

Without this step, all authentication operations will fail.


Anonymous Sign-In

Anonymous sign-in is the most common authentication method for mobile games.

It allows a user to be authenticated without providing any credentials, while still receiving a unique and persistent user ID.

This approach is ideal for:

  • instant access without login screens
  • guest users
  • saving progress automatically
  • upgrading to a permanent account later

When anonymous sign-in succeeds:

  • a unique user ID (UID) is created
  • the user remains signed in across app restarts
  • the UID can be immediately used with other Firebase services

If sign-in fails, the failure callback can be used to handle network or configuration errors.


Google Sign-In

Google Sign-In allows users to authenticate using their Google account.

This is one of the most common and reliable authentication methods for mobile games, as most Android users already have a Google account configured on their device.

Typical use cases:

  • converting a guest (anonymous) user into a permanent account
  • providing a one-tap sign-in experience
  • restoring user progress across devices
  • reducing friction compared to manual account creation

When Google Sign-In succeeds:

  • the current Firebase user is authenticated using Google credentials
  • the user receives a stable and permanent UID
  • the account can be safely used across sessions and devices

Google Sign-In can be used in two main scenarios:

  • Direct sign-in for new or returning users
  • Account linking, where an anonymous user is upgraded to a Google-backed account without losing data

Important notes:

  • Google Sign-In requires SHA-1 and SHA-256 fingerprints to be configured in the Firebase Console
  • Google Sign-In can also be used for reauthentication when required

Email and Password Authentication

Email and password authentication provides a traditional account system similar to classic web or PC applications.

This method is suitable for projects that require:

  • explicit user accounts
  • manual login credentials
  • password recovery flows
  • email-based verification

Email authentication supports the following operations:

  • creating new user accounts
  • signing in with existing credentials
  • sending password reset emails
  • sending email verification messages
  • updating email and password after authentication

Typical usage patterns:

  • players creating an account via a registration screen
  • allowing users to log in on multiple devices using the same credentials
  • combining email authentication with other providers via account linking

Important notes:

  • email verification is optional but recommended for permanent accounts
  • some sensitive operations (email/password update, account deletion) may require recent reauthentication
  • email/password accounts can later be linked with Google or other providers

Email-based authentication works well for projects that need full control over account lifecycle and user credentials.


Checking Authentication State and User Data

After a successful sign-in, it is common to immediately read basic information about the authenticated user and store it in game state or UI variables.

Typical usage pattern:

  • retrieve the current user ID
  • retrieve available profile information (display name, email)
  • store these values for later use in gameplay logic or UI

Common use cases include:

  • identifying the player in backend systems
  • associating save data with a specific user
  • displaying account information in profile screens

Important notes:

  • getters return values for the currently authenticated user
  • some fields (such as display name or email) may be empty depending on the sign-in method
  • getters are safe to call after a successful authentication flow

This pattern is commonly used right after sign-in or during game startup to initialize user-related state without making additional network requests.


Updating User Profile

Firebase Authentication allows updating profile data for the currently authenticated user.

Supported updates include:

  • display name
  • photo URL
  • email address
  • password

These operations may require recent authentication, depending on account security rules.

Typical use cases:

  • profile or account settings screens
  • allowing users to customize their public profile
  • account recovery or credential updates

After updating profile data, it is recommended to reload the user to ensure local state is up to date.


Reauthentication

Some sensitive operations require the user to be recently authenticated.

This includes:

  • updating email
  • updating password
  • deleting the account

If such an operation fails due to authentication age, the user must reauthenticate.

Supported reauthentication methods:

  • email and password
  • Google Sign-In

Reauthentication does not create a new session or user.
It only refreshes the security credentials of the current user.


Linking Authentication Providers

Linking allows attaching multiple authentication providers to a single Firebase user.

This is commonly used to:

  • upgrade an anonymous account to a permanent one
  • allow login via multiple methods
  • preserve user data across different sign-in flows

Supported linking methods:

  • email and password
  • Google account

After linking succeeds:

  • the same user ID (UID) is preserved
  • existing data in Firebase services remains intact

You can retrieve all linked providers at any time to update UI or account settings.


Reloading User Data

Firebase caches user profile data locally.

To ensure the latest state is loaded from the server, you can explicitly reload the current user.

Reloading updates:

  • email verification status
  • linked providers
  • profile metadata

This is especially useful after:

  • email verification
  • profile updates
  • linking new providers

Deleting the User Account

Firebase Authentication allows permanently deleting the currently authenticated user.

This operation:

  • removes the account from Firebase Authentication
  • invalidates all associated sessions
  • does not automatically delete data in other Firebase services

For safety, this operation often requires reauthentication beforehand.


Authentication State Listener

Firebase provides a global authentication state listener.

This listener is triggered when:

  • a user signs in
  • a user signs out
  • the active user changes

Typical use cases:

  • reacting to login/logout globally
  • updating UI automatically
  • synchronizing authentication-dependent systems

Signing Out

Signing out removes the current authentication session from the device.

After signing out, it is important to explicitly reset all user-related state inside the game, since Firebase no longer considers the user authenticated.

Typical actions performed after sign-out:

  • clear stored user ID
  • clear cached profile data (display name, email)
  • reset UI elements that depend on authentication state
  • optionally redirect the player to a login or start screen

Important notes:

  • after sign-out, all authentication getters return empty or invalid values
  • any features that rely on authentication should be disabled until a new sign-in occurs
  • sign-out does not delete the user account, it only removes the local session

This pattern is commonly used for explicit logout flows or account switching scenarios, ensuring that no stale user data remains active after the session ends.


Summary

Firebase Authentication provides a flexible and reliable way to manage user identity in Unreal Engine projects.

By using anonymous sign-in as a default entry point and adding optional authentication methods when needed, you can support both casual and persistent user experiences while keeping authentication logic simple and scalable.