OAuth2.0 Access Token Authorization Using Service Account.
class ServiceAuth
A ServiceAuth constructor.
explicit ServiceAuth(TimeStatusCallback timeCb, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
timeCb
- The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload. -
clientEmail
- The service account client Email. -
projectId
- The service account project ID. -
privateKey
- The service account private key. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A ServiceAuth constructor.
explicit ServiceAuth(TimeStatusCallback timeCb, const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
timeCb
- The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload. -
safile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of service account key file. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A ServiceAuth constructor.
explicit ServiceAuth(const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
clientEmail
- The service account client Email. -
projectId
- The service account project ID. -
privateKey
- The service account private key. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A ServiceAuth constructor.
explicit ServiceAuth(const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
safile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of service account key file. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
Set the timestamp for the JWT token generation and signing process when authenticated with ServiceAuth
and CustomAuth
.
Once the timestamp was set, the internal timestamp value will be set and increased by the millisec of the system timer count since it was set, deviced by 1000.
The precision of the system timer depends on the crystal oscillator.
void setTime(uint32_t ts)
Params:
ts
- The UNIX timestamp.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
ID Token Authorization Using Service Account with custom claims and UID.
For more details about claims, please visit https://firebase.google.com/docs/auth/admin/custom-claims.
class CustomAuth
A CustomAuth constructor.
explicit CustomAuth(TimeStatusCallback timeCb, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
timeCb
- The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload. -
apiKey
- The web API key of the project. -
clientEmail
- The service account client Email. -
projectId
- The service account project ID. -
privateKey
- The service account private key. -
uid
- The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance. -
claims
- Optional custom claims to include in the Security Rules auth / request.auth variables. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A CustomAuth constructor.
explicit CustomAuth(TimeStatusCallback timeCb, const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
timeCb
- The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload. -
safile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of service account key file. -
apiKey
- The web API key of the project. -
uid
- The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance. -
claims
- Optional custom claims to include in the Security Rules auth / request.auth variables. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A CustomAuth constructor.
explicit CustomAuth(const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
apiKey
- The web API key of the project. -
clientEmail
- The service account client Email. -
projectId
- The service account project ID. -
privateKey
- The service account private key. -
uid
- The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance. -
claims
- Optional custom claims to include in the Security Rules auth / request.auth variables. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A CustomAuth constructor.
explicit CustomAuth(const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
safile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of service account key file. -
apiKey
- The web API key of the project. -
uid
- The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance. -
claims
- Optional custom claims to include in the Security Rules auth / request.auth variables. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
Set the timestamp for the JWT token generation and signing process when authenticated with ServiceAuth
and CustomAuth
.
Once the timestamp was set, the internal timestamp value will be set and increased by the millisec of the system timer count since it was set, deviced by 1000.
The precision of the system timer depends on the crystal oscillator.
void setTime(uint32_t ts)
Params:
ts
- The UNIX timestamp.
Clear the internal credentials.
void clear()
Set the additional claims.
Because this library does not include JSON library to parse the claims, this function will replace or set the internal claims data.
For more details about claims, please visit https://firebase.google.com/docs/auth/admin/custom-claims.
void setClaims(const String &claims)
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Params:
claims
- The custom claims to include in the Security Rules auth / request.auth variables.
User Sign-In Authentication.
class UserAuth
A UserAuth constructor.
explicit UserAuth(const String &api_key, const String &email, const String &password, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
api_key
- The API key which can be obtained from Firebase console > Project Overview > Project settings. -
email
- The Email of user in the project. -
password
- The password of user in the project. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value.
A UserAuth constructor.
explicit UserAuth(const file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Save the user config data.
bool save(file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.
Non-Authentication.
class UserAuth
A NoAuth constructor.
NoAuth()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
OAuth2.0 Access Token Authorization
class AccessToken
A AccessToken constructor.
explicit AccessToken(const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "", const String &client_id = "", const String &client_secret = "")
Params:
-
token
- The access token. -
expire
- The expiry period in seconds (less than 3600), 3300 is the default value. -
refresh
- The refresh token. -
client_id
- The Client ID. -
client_secret
- The Client secret.
A AccessToken constructor.
explicit AccessToken(const file_config_data &tokenFile)
Params:
tokenFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theAccessToken
credentials will be saved to or read from.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Save the user config data.
bool save(file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.
ID Token Authorization Using Custom Token
class CustomToken
A CustomToken constructor.
explicit CustomToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)
Params:
-
api_key
- API key can be obtained from Firebase console > Project Overview > Project settings. -
token
- The custom token (jwt signed token). -
expire
- Expiry period in seconds (less than 3600), 3300 is the default value.
A CustomToken constructor.
explicit CustomToken(const file_config_data &tokenFile)
Params:
tokenFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theCustomToken
credentials will be saved to or read from.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Save the user config data.
bool save(file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.
ID token Authorization.
class IDToken
A IDToken constructor.
explicit IDToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "")
Params:
-
api_key
- API key can be obtained from Firebase console > Project Overview > Project settings. -
token
- The ID token. -
expire
- Expire period in seconds. -
refresh
- The refresh token.
A IDToken constructor.
explicit IDToken(const file_config_data &tokenFile)
Params:
tokenFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theCustomToken
credentials will be saved to or read from.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Save the user config data.
bool save(file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.
The Realtime Database access with the database Secret.
class LegacyToken
A LegacyToken constructor.
explicit LegacyToken(const String &token)
Params:
token
- TheRealtime Database
secret key.
A LegacyToken constructor.
explicit LegacyToken(const file_config_data &tokenFile)
Params:
tokenFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theCustomToken
credentials will be saved to or read from.
Clear the internal credentials.
void clear()
Returns the internal user_auth_data reference.
user_auth_data &get()
Returns:
user_auth_data
- Return internal user_auth_data reference.
Returns the status of this class initialization.
bool isInitialized() const
Returns:
bool
- Return true if initialized.
Save the user config data.
bool save(file_config_data &userFile)
Params:
userFile
- The filesystem data (file_config_data
) obtained fromFileConfig
class object of file that theUserAuth
credentials will be saved to or read from.