Menu

class: firebase

[31:14] (extern: com.lehman.aussomserver.connectors.AussomFirebase) extends: object

The firebase class provides Firebase Authentication functionality for verifying OAuth2 tokens, managing users, and generating email action links. It wraps the Google Firebase Admin Java SDK. Initialize with a Firebase service account JSON string: fb = new firebase(file.read("app_data/service-account.json")); Verify an ID token (core OAuth2 flow): token = fb.verifyIdToken(idTokenString); uid = token.uid;

Methods

  • firebase (string ServiceAccountJson)

    Creates a new firebase authentication object initialized with the provided service account JSON string.

    • @p ServiceAccountJson is a string with the Firebase service account JSON credentials.
    • @r this object
  • _init (string ServiceAccountJson)

  • verifyIdToken (string IdToken, bool CheckRevoked = false)

    Verifies a Firebase ID token string and returns a map with the decoded token data including uid, email, name, emailVerified, issuer, picture, and claims.

    • @p IdToken is a string with the Firebase ID token.
    • @p CheckRevoked is an optional bool to check if the token has been revoked. (default: false)
    • @r A map with the decoded token data.
  • createSessionCookie (string IdToken, int ExpiresInMs)

    Creates a session cookie from an ID token. The cookie can be verified later with verifySessionCookie().

    • @p IdToken is a string with the Firebase ID token.
    • @p ExpiresInMs is an int with the cookie expiration time in milliseconds (min 5 minutes, max 14 days).
    • @r A string with the session cookie.
  • verifySessionCookie (string Cookie, bool CheckRevoked = false)

    Verifies a session cookie and returns the decoded token data.

    • @p Cookie is a string with the session cookie.
    • @p CheckRevoked is an optional bool to check if the session has been revoked. (default: false)
    • @r A map with the decoded token data.
  • createCustomToken (string Uid, map Claims)

    Creates a custom token for the given UID. Custom tokens can be used by client SDKs to sign in.

    • @p Uid is a string with the user UID.
    • @p Claims is an optional map with custom claims to include.
    • @r A string with the custom token.
  • getUser (string Uid)

    Gets a user record by UID.

    • @p Uid is a string with the user UID.
    • @r A map with the user record data.
  • getUserByEmail (string Email)

    Gets a user record by email address.

    • @p Email is a string with the email address.
    • @r A map with the user record data.
  • getUserByPhone (string PhoneNumber)

    Gets a user record by phone number.

    • @p PhoneNumber is a string with the phone number in E.164 format (e.g., "+15555551234").
    • @r A map with the user record data.
  • createUser (map Options)

    Creates a new user with the provided options map. Supported keys: email, password, displayName, phoneNumber, photoUrl, emailVerified (bool), disabled (bool).

    • @p Options is a map with the user properties to set.
    • @r A map with the created user record data.
  • updateUser (string Uid, map Options)

    Updates an existing user with the provided options map. Supported keys: email, password, displayName, phoneNumber, photoUrl, emailVerified (bool), disabled (bool).

    • @p Uid is a string with the user UID to update.
    • @p Options is a map with the user properties to update.
    • @r A map with the updated user record data.
  • deleteUser (string Uid)

    Deletes a user by UID.

    • @p Uid is a string with the user UID to delete.
    • @r null
  • setCustomClaims (string Uid, map Claims)

    Sets custom claims on a user. These claims are included in ID tokens and can be used for role-based access control. Pass an empty map to clear all custom claims.

    • @p Uid is a string with the user UID.
    • @p Claims is a map with the custom claims to set.
    • @r null
  • revokeRefreshTokens (string Uid)

    Revokes all refresh tokens for a user, forcing them to re-authenticate on all devices.

    • @p Uid is a string with the user UID.
    • @r null
  • listUsers (string PageToken = "", int MaxResults = 1000)

    Lists users with pagination support.

    • @p PageToken is an optional string with the page token from a previous listUsers call. Pass empty string for first page.
    • @p MaxResults is an optional int with the max number of users to return per page. (default: 1000)
    • @r A map with 'users' (list of user maps) and 'nextPageToken' (string, empty if no more pages).
  • generatePasswordResetLink (string Email)

    Generates a password reset email link for the given email.

    • @p Email is a string with the user's email address.
    • @r A string with the password reset link.
  • generateEmailVerificationLink (string Email)

    Generates an email verification link for the given email.

    • @p Email is a string with the user's email address.
    • @r A string with the email verification link.
  • generateSignInWithEmailLink (string Email, map ActionCodeSettings)

    Generates a sign-in with email link.

    • @p Email is a string with the user's email address.
    • @p ActionCodeSettings is a map with settings. Required key: 'url' (string, the continue URL). Optional keys: 'handleCodeInApp' (bool).
    • @r A string with the sign-in link.