Skip to content

Files

Latest commit

 

History

History
263 lines (146 loc) · 5.14 KB

firebase_app.md

File metadata and controls

263 lines (146 loc) · 5.14 KB

FirebaseApp

Description

The Firebase App class that handles the authentication/authorization task.

class FirebaseApp

Functions

  1. 🔹 bool isInitialized() const

Get the app initialization status.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 void loop(JWTClass *jwt = nullptr)

The authentication and async tasks handler.

Since v2.0.0, the async task in any AsyncClient's queue that belongs to this app will be maintained to run which includes the tasks in the AsyncClient's queue that was assigned to the initializeApp function.

Then calling individual Firebase service's class's loop is not neccessary and can be ignored.

void loop(JWTClass *jwt = nullptr)

Params:

  • jwt - Optional. The pointer to JWTClass class object to handle the JWT token generation and signing.
  1. 🔹 bool ready()

Get the authentication/autorization process status.

bool ready()

Returns:

  • bool - Return true if the auth process was finished. Returns false if isExpired() returns true.
  1. 🔹 void getApp(T &app)

Appy the authentication/authorization credentials to the Firebase services app.

void getApp(T &app)

Params:

  • app - The Firebase services calss object e.g. RealtimeDatabase, Storage, Messaging, CloudStorage and CloudFunctions.
  1. 🔹 String getToken() const

Get the auth token.

String getToken() const

Returns:

  • String - String of auth tokens based on the authentication/authoeization e.g. ID token and access token.
  1. 🔹 firebase_token_type getTokenType()

Get the token type.

firebase_token_type getTokenType()

Returns:

  • firebase_token_type enums - The enums are included following: token_type_id (3), token_type_access (2), token_type_legacy (1) and token_type_no (0).
  1. 🔹 String getRefreshToken() const

Get the refresh token.

String getRefreshToken() const

Returns:

  • String - String of refresh token after user sign in or authorization using ID token.
  1. 🔹 String getUid() const

Get unique identifier.

String getUid() const

Returns:

  • String - String of unique identifier after user sign in or authorization using ID token.
  1. 🔹 bool isAuthenticated() const

Get the authentication status since app initialized.

bool isAuthenticated() const

Returns:

  • bool - Return true once authenticated since initialized. It will reset when app re-initialized and user management task was executed.
  1. 🔹 bool isExpired()

Get the auth token expiration status.

bool isExpired()

Returns:

  • bool - Return true if auth token was expired upon the expire period setup.
  1. 🔹 unsigned long ttl()

Get the remaining time to live of token until expired.

unsigned long ttl()

Params:

  • unsigned long - The integer value of ttl.
  1. 🔹 void setCallback(AsyncResultCallback cb)

Set the async result callback function.

void setCallback(AsyncResultCallback cb)

Params:

  • cb - The async result callback function (AsyncResultCallback).
  1. 🔹 void setAsyncResult(AsyncResult &aResult)

Set the async result class object.

void setAsyncResult(AsyncResult &aResult)

Params:

  • aResult - The async result (AsyncResult).
  1. 🔹 void setUID(const String &uid)

Set the UID for authentication task.

The UID will be applied when used with the async result callback only.

The async result object set via initializeApp and FirebaseApp::setAsyncResult will not take effect.

void setUID(const String &uid)

Params:

  • uid - The unique identifier for the authentication task.
  1. 🔹 void setTime(uint32_t sec)

Set the app UNIX timestamp.

void setTime(uint32_t sec)

Params:

  • sec - The UNIX timestamp in seconds.

Params:

  • jwtClass - The JWT token processor object.
  1. 🔹 auth_data_t *getAuth()

Get the pointer to the internal auth data.

auth_data_t *getAuth()

Returns:

  • auth_data_t* - The pointer to internal auth data.
  1. 🔹 void autoRefresh(bool enable)

Set the option to enable/disable re-authentication.

void autoAuthenticate(bool enable)

Params:

  • enable - Set to true to enable or false to disable.
  1. 🔹 void authenticate()

Force library to re-authenticate (refresh the auth token).

void authenticate()
  1. 🔹 void setJWTProcessor(JWTClass &jwtClass)

Set the JWT token processor object (DEPRECATED).

This function should be executed before calling initializeApp.

Use FirebaseApp::loop function instead for assigning the JWT token processor for individual app (thread safe).

void setJWTProcessor(JWTClass &jwtClass)

Params:

  • jwtClass - The pointer to JWTClass class object to handle the JWT token generation and signing.