Skip to content

Authentication

YYBartT edited this page Aug 29, 2024 · 8 revisions

Authentication

Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more. Check the official page for more information.

Setup

Note

The SDK version is only available for Android, iOS and Web targets; if you're targeting other devices please follow the steps for REST API.

Before starting to use any Firebase extensions, you are required to follow some initial configuration steps.

Compatibility

Below is the GameMaker compatibility table for each provider depending on the target platform (keep in mind that the REST API can be used on every platform).

Provider Android iOS Web REST API
Custom yes yes yes yes
Anonymous yes yes yes yes
Email/Password yes yes yes yes
Phone yes yes yes yes
Google yes yes yes yes
Apple yes yes yes yes
Facebook yes yes yes yes
Google Play yes no no yes
GameCenter no yes no no

Auth Configuration

These are the available authentication setup guides that you can follow to implement the desired authentication method in your project.

Functions

The functions listed here are given for working with Firebase Authentication extension.

These functions are only available on SDK targets (Android, iOS, Web). Check the compatibility table above.



Back To Top

FirebaseAuthentication_ChangeDisplayName

This function changes a user's display name and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function call requires re-authentication.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ChangeDisplayName(name)
Argument Type Description
name String The new display name to be assigned to the current user.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ChangeDisplayName"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ChangeDisplayName("YoYoUser");

In the code above we initiate a task to change the display name of the user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ChangeDisplayName")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("The display name was changed.");
    }
    else
    {
        show_debug_message("There was an error changing the display name.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ChangeEmail

This function changes a user's email and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function call requires re-authentication.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ChangeEmail(email)
Argument Type Description
email String The new email address to be assigned to the current user.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ChangeEmail"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ChangeEmail("[email protected]");

In the code above we initiate a task to change the email of the user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ChangeEmail")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("The email was changed.");
    }
    else
    {
        show_debug_message("There was an error changing the email.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ChangePassword

This function changes a user's password and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function call requires re-authentication.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ChangePassword(password)
Argument Type Description
password String The new password for the current user account.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ChangePassword"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ChangePassword("Password123!");

In the code above we initiate a task to change the password of the user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ChangePassword")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("The email was changed.");
    }
    else
    {
        show_debug_message("There was an error changing the email.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ChangePhotoURL

This function changes a user's photo URL and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function call requires re-authentication.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ChangePhotoURL(url)
Argument Type Description
url String The new photo url to be assign to the current user account.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ChangePhotoURL"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ChangePhotoURL(global.photoURL);

In the code above we initiate a task to change the photo URL of the user to a new value store in a global variable (global.photoURL). The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ChangePhotoURL")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("The photo URL was changed.");
    }
    else
    {
        show_debug_message("There was an error changing the photo URL.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_DeleteAccount

This function deletes the current user account and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function call requires re-authentication.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_DeleteAccount()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_DeleteAccount"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_DeleteAccount();

In the code above we initiate a task to delete the current user account. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_DeleteAccount")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("The account was deleted.");
    }
    else
    {
        show_debug_message("There was an error deleting the account.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_GetDisplayName

This function returns the display name of the current user.


Syntax:

FirebaseAuthentication_GetDisplayName()



Returns:

String


Example:

var _displayName = FirebaseAuthentication_GetDisplayName();

The code above will retrieve the current user's display name and store it in a local variable.




Back To Top

FirebaseAuthentication_GetEmail

This function returns the email of the current user.


Syntax:

FirebaseAuthentication_GetEmail()



Returns:

String


Example:

var _email = FirebaseAuthentication_GetEmail();

The code above will retrieve the current user's email and store it in a local variable.




Back To Top

FirebaseAuthentication_GetEmailVerified

This function returns whether or not the email of the current user is verified.


Syntax:

FirebaseAuthentication_GetEmailVerified()



Returns:

Boolean


Example:

var _emailVerified = FirebaseAuthentication_GetEmailVerified();

if (!_emailVerified)
{
    listenerId = FirebaseAuthentication_SendEmailVerification();
}

The code above will check if the current user's email is verified, and if it's not, it'll call FirebaseAuthentication_SendEmailVerification to start the verification process.




Back To Top

FirebaseAuthentication_GetIdToken

This function requests a callback to get the current idToken and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_GetIdToken()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_GetIdToken"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String The idToken (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_GetIdToken();

In the code above we request for the current session's idToken. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ReauthenticateWithEmail")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_GetLocalId

This function returns the local identifier (uid) of the current user.

Note

This function returns the same value as FirebaseAuthentication_GetUID.


Syntax:

FirebaseAuthentication_GetLocalId()



Returns:

String


Example:

var _uid = FirebaseAuthentication_GetLocalId();

The code above will retrieve the local identifier (uid) of the current user and store it in a local variable.




Back To Top

FirebaseAuthentication_GetPhotoUrl

This function returns the URL of the current user's photo.


Syntax:

FirebaseAuthentication_GetPhotoUrl()



Returns:

String


Example:

var _photoUrl = FirebaseAuthentication_GetPhotoUrl();

The code above will retrieve current user's photo URL and store it in a local variable.




Back To Top

FirebaseAuthentication_GetProviderUserInfo

This function returns an array of structs with the information of each provider of the current user (or an empty string if unavailable). Below is a sample of the returned information string parsed as an array (using the json_parse function) for a user authenticated with Apple, Facebook, Google Play Games and Phone.

[
    {
        "email":"**@privaterelay.appleid.com",
        "providerId":"apple.com",
        "rawId":"**",
        "federatedId":"**"
    },
    {
        "displayName":"**",
        "photoUrl":"https:**",
        "providerId":"facebook.com",
        "rawId":"**",
        "federatedId":"**"
    },
    {
        "displayName":"**",
        "photoUrl":"https:**",
        "providerId":"playgames.google.com",
        "rawId":"**",
        "federatedId":"**"
    },
    {
        "phoneNumber":"**",
        "providerId":"phone"
    }
]

Syntax:

FirebaseAuthentication_GetProviderUserInfo()



Returns:

String


Example:

var _providerUserInfo = FirebaseAuthentication_GetProviderUserInfo();

The code above will return a JSON formatted string of an array containing provider information.




Back To Top

FirebaseAuthentication_GetUID

This function returns the unique identifier (uid) of the current user.

Note

This function returns the same value as FirebaseAuthentication_GetLocalId.


Syntax:

FirebaseAuthentication_GetUID()



Returns:

String


Example:

var _uid = FirebaseAuthentication_GetUID();

The code above will retrieve the unique identifier (_uid) of the current user and stores it in a local variable.




Back To Top

FirebaseAuthentication_GetUserData_raw

This function returns a raw user representation as a JSON formatted string. Below is a sample of the returned information string parsed as a struct (using the json_parse function) with information for some of the supported providers: Apple, Facebook, Google Play Games and Phone.

{
   "kind":"identitytoolkit#GetAccountInfoResponse",
   "users":[
      {
         "email":"**",
         "localId":"**8",
         "emailVerified":true,
         "phoneNumber":true,
         "providerUserInfo":[
            {
               "email":"**@privaterelay.appleid.com",
               "providerId":"apple.com",
               "rawId":"**",
               "federatedId":"**"
            },
            {
               "displayName":"**",
               "photoUrl":"https:**",
               "providerId":"facebook.com",
               "rawId":"**",
               "federatedId":"**"
            },
            {
               "displayName":"**",
               "photoUrl":"https:**",
               "providerId":"playgames.google.com",
               "rawId":"**",
               "federatedId":"**"
            },
            {
               "phoneNumber":"**",
               "providerId":"phone"
            }
         ]
      }
   ]
}

Note

It is recommended to use one of the FirebaseAuthentication_Get* functions to get the information you need.


Syntax:

FirebaseAuthentication_GetUserData_raw(arg)
Argument Type Description
arg Any The argument to be passed in



Returns:

String


Example:

var _raw_user_data = FirebaseAuthentication_GetUserData_raw();

The code above will return a JSON formatted string of an array with raw user data.




Back To Top

FirebaseAuthentication_LinkWithEmailPassword

This function establishes a link between an email/password pair and the current user (used for Email Authentication based authentication). The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_LinkWithEmailPassword(email, pass)
Argument Type Description
email String The email to link the current user to.
pass String The password to link to the current user account.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_LinkWithEmailPassword"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_LinkWithEmailPassword("[email protected]", "myPass123!");

In the code above we attempt to link the current user with a email/password pair. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_LinkWithEmailPassword")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message("There was an error linking email/pass to current user.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_LinkWithOAuthCredential

This function establishes a link between an OAuth credential and the current user (used for Apple Authentication, ?{page.logins_authentication#Facebook_Authentication}, Google Authentication and Google Play Services Authentication based authentications). The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_LinkWithOAuthCredential(token, token_kind, provider, redirect_uri=undefined)
Argument Type Description
token String The provider token.
token_kind String One of the provided strings "id_token", "access_token" or "serverAuthCode"
provider String The provider identifier (e.g. "apple.com", "google.com", etc.)
redirect_uri String Only for REST API (can be checked on the Firebase Console for your provider)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_LinkWithOAuthCredential"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_LinkWithOAuthCredential(token, token_kind, provider, redirect_uri);

In the code above we attempt to link the current user with an OAuth credential. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_LinkWithEmailPassword")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message("There was an error linking OAuth credential to current user.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_LinkWithPhoneNumber

This function establishes a link between a phone number and the current user. The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_LinkWithPhoneNumber(phone, code, session_info)
Argument Type Description
phone String The phone number, including country number (i.e.: "+44123456789")
code String The code from the SMS.
session_info String Session info from the re-catcha puzzle.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_LinkWithPhoneNumber"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_LinkWithPhoneNumber(phone, code, sessionInfo);

In the code above we attempt to link the current user with a phone number. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_LinkWithPhoneNumber")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message("There was an error linking phone number to current user.");
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ReauthenticateWithEmail

This function re-authenticates the current user using an email/password (used for Email Authentication based authentication). The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ReauthenticateWithEmail(email, pass)
Argument Type Description
email String The email to link the current user to.
pass String The password to link to the current user account.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ReauthenticateWithEmail"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ReauthenticateWithEmail("[email protected]", "myPass123!");

In the code above we attempt to re-authenticate the current user with a email/password pair. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ReauthenticateWithEmail")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ReauthenticateWithOAuth

This function re-authenticates the current user using an OAuth credential (used for Apple Authentication, Facebook Authentication, Google Authentication and Google Play Services Authentication). The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ReauthenticateWithOAuth(token, token_kind, provider, redirect_uri)
Argument Type Description
token String The provider token.
token_kind String One of the provided strings "id_token" or "access_token" or "serverAuthCode"
provider String The provider identifier (i.e.: "apple.com", "google.com", etc.)
redirect_uri String Only for REST API (can be checked on the Firebase Console for your provider)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ReauthenticateWithOAuth"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ReauthenticateWithOAuth(token, token_kind, provider, redirect_uri);

In the code above we attempt to re-authenticate the current user with an OAuth credential. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ReauthenticateWithOAuth")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_ReauthenticateWithPhoneNumber

This function re-authenticates the current user using a phone number. The returned value is a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_ReauthenticateWithPhoneNumber(phone, code, session_info)
Argument Type Description
phone String The phone number, including country number (i.e.: "+44123456789")
code String The code from the SMS.
session_info String Session info from the re-catcha puzzle.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ReauthenticateWithPhoneNumber"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String User raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ReauthenticateWithPhoneNumber(phone, code, sessionInfo);

In the code above we try to re-authenticate the current user with a phone number. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_ReauthenticateWithPhoneNumber")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message(json_parse(async_load[? "value"]));
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_RecaptchaParams

This function requests a recaptchaSiteKey and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_RecaptchaParams()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_RecaptchaParams"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with recaptchaSiteKey (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_RecaptchaParams();

In the code above we attempt to get the recaptcha parameters that can be used for phone number authentication (see FirebaseAuthentication_LinkWithPhoneNumber). The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_RecaptchaParams")
{
    if (async_load[? "status"] == 200)
    {
        var data = json_decode(async_load[? "value"]);
        var recaptchaSiteKey = data.recaptchaSiteKey;
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_RefreshUserData

This function can be used to refresh the user data and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_RefreshUserData()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_RefreshUserData"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the recaptchaSiteKey value (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_RefreshUserData();

In the code above we attempt to refresh the current user's data. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_RefreshUserData")
{
    if (async_load[? "status"] == 200)
    {
        var data = json_decode(async_load[? "value"]);
        show_debug_message(data);
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SendEmailVerification

This function sends an email verification to the current user (used for Email Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SendEmailVerification(email)
Argument Type Description
email String The email to be verified.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SendEmailVerification"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SendEmailVerification();

In the code above we attempt to send an email verification to the current user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_RefreshUserData")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Email verification succeeded");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SendPasswordResetEmail

This function sends a password reset email to the current user (used for Email Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SendPasswordResetEmail(email)
Argument Type Description
email String The email to send the password reset email to.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SendPasswordResetEmail"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String The return value (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SendPasswordResetEmail("[email protected]");

In the code above we attempt to send a password reset email to the current user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_SendPasswordResetEmail")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Email verification succeeded");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SendVerificationCode

This function sends a verification code and requests for a sessionInfo key (used for Phone Authentication based authentication), it then returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SendVerificationCode(phoneNumber, recaptchaToken)
Argument Type Description
phoneNumber String The phone number to send the verification code to, including country code (i.e.: "+44123456789")
recaptchaToken String The recaptcha token (obtained from solving the reCAPTCHA puzzle).



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SendVerificationCode"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the sessionInfo **value (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SendVerificationCode(phoneNumber, recaptchaToken);

In the code above we attempt to send a verification code to the current user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_SendVerificationCode")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Verification code sent!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignIn_Anonymously

This function signs in a user anonymously and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignIn_Anonymously()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignIn_Anonymously"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignIn_Anonymously();

In the code above we attempt to sign in the current user anonymously. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_SignIn_Anonymously")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignIn_Email

This function signs in a user with an email and password (used for Email Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignIn_Email(email, pass)
Argument Type Description
email String The email to sign in with.
pass String The password associated with the email above (not the actual email's password).



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignIn_Email"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignIn_Email("[email protected]", "mypass123!");

In the code above we attempt to sign in the current user using an email/password. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_SignIn_Email")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignIn_OAuth

This function signs in a user with an OAuth credential (used for Apple Authentication, Facebook Authentication, Google Authentication and Google Play Services Authentication based authentications) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignIn_OAuth(token, token_kind, provider, redirect_uri=undefined)
Argument Type Description
token String The provider token.
token_kind String One of the provided strings "id_token", "access_token" or "serverAuthCode"
provider String The provider identifier (i.e.: "apple.com", "google.com", etc.)
redirect_uri String The redirect URI if using REST API (can be checked on the Firebase Console for your provider)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignIn_OAuth"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignIn_OAuth(token, token_kind, provider, redirect_uri);

In the code above we attempt to sign in the current user using an OAuth credential. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "type"] == "FirebaseAuthentication_SignIn_OAuth")
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event type, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignInWithCustomToken

This function tries to sign in a user with a given custom token. Use this function after you retrieve a Firebase Auth Custom Token from your server (used with Custom Authentication). The function returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignInWithCustomToken(customToken)
Argument Type Description
customToken String The user's Firebase custom token.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignInWithCustomToken"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignIn_OAuth(token, token_kind, provider, redirect_uri);

In the code above we attempt to sign in the current user using an OAuth credential. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignInWithPhoneNumber

This function signs in a user with a phone number (used for Phone Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignInWithPhoneNumber(phone, code, session_info)
Argument Type Description
phone String The phone number, including country code (i.e.: "+44123456789")
code String The code from the SMS.
session_info String Session info from the re-captcha puzzle.



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignInWithPhoneNumber"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignInWithPhoneNumber(phone, code, sessionInfo);

In the code above we attempt to sign in the current user using a phone number. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_SignOut

This function signs out the current user.


Syntax:

FirebaseAuthentication_SignOut()



Returns:

N/A


Example:

FirebaseAuthentication_SignOut();

The code above will log the current user out of the Firebase Authentication system.




Back To Top

FirebaseAuthentication_SignUp_Email

This function signs up a user with an email and password (used for Email Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_SignUp_Email(email, pass)
Argument Type Description
email String The email to to be used during sign-up.
pass String The password to be associated with the email provided (not the actual email's password)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_SignUp_Email"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_SignUp_Email("[email protected]", "mypass123!");

In the code above we attempt to sign up the current user using an email and password. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Signed up successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

FirebaseAuthentication_UnlinkProvider

This function unlinks a provider from the current user and returns a listener identifier that can be used for tracking progress on the request.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

FirebaseAuthentication_UnlinkProvider(provider_identifer)
Argument Type Description
provider_identifer String The provider identifier (e.g. "apple.com", "google.com", "phone", etc.)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_UnlinkProvider"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_UnlinkProvider("apple.com");

In the code above we attempt to unlink the provider "apple.com" from the current user. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Unliked provider successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_LinkWithGameCenter

This function links a Game Center account to the current user (used for GameCenter Authentication) based authentication) and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on iOS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_LinkWithGameCenter()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_LinkWithGameCenter"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_LinkWithGameCenter();

In the code above we attempt to link the current user to a game center account. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Account linked successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_LinkWithProvider

This function links the user account with a specific provider (the user needs to be signed in) and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on Android, iOS and Web.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_LinkWithProvider(provider)
Argument Type Description
provider String The provider identifier (i.e.: "apple.com", "google.com", etc.)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "SDKFirebaseAuthentication_LinkWithProvider"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = SDKFirebaseAuthentication_LinkWithProvider("apple.com");

In the code above we attempt to link the current user to the "apple.com" provider (see Apple Authentication for more information on this authentication method). The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Account linked successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_ReauthenticateWithGameCenter

This function re-authenticates the user using a Game Center account (used for GameCenter Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on iOS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_ReauthenticateWithGameCenter()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "FirebaseAuthentication_ReauthenticateWithGameCenter"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = FirebaseAuthentication_ReauthenticateWithGameCenter();

In the code above we attempt to re-authenticate the current user using a game center account. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Account linked successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_ReauthenticateWithProvider

This function re-authenticates the user account with a specific provider (the user needs to be signed in) and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on Android, iOS and Web.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_ReauthenticateWithProvider(provider)
Argument Type Description
provider String The provider identifier (i.e.: "apple.com", "google.com", etc.)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "SDKFirebaseAuthentication_ReauthenticateWithProvider"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = SDKFirebaseAuthentication_ReauthenticateWithProvider("apple.com");

In the code above we attempt to re-authenticate the current user to the "apple.com" provider (see Apple Authentication for more information on this authentication method). The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Account re-authenticated successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_SignIn_GameCenter

This function signs in the current user with a Game Center account (used for GameCenter Authentication based authentication) and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on iOS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_SignIn_GameCenter()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "SDKFirebaseAuthentication_SignIn_GameCenter"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data (if status == 200)
errorMessage String The readable error message

Example:

listenerId = SDKFirebaseAuthentication_SignIn_GameCenter();

In the code above we attempt to sign in the current using a game center account. The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("Account linked successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.




Back To Top

SDKFirebaseAuthentication_SignInWithProvider

This function signs in the user using the browser account native to a specific provider and returns a listener identifier that can be used for tracking progress on the request.

Warning

This function is only available on Android, iOS and Web.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

SDKFirebaseAuthentication_SignInWithProvider(provider)
Argument Type Description
provider String The provider identifier (i.e.: "apple.com", "google.com", etc)



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "SDKFirebaseAuthentication_SignInWithProvider"
listener Real The asynchronous listener ID.
status Real The HTTP status response code (see reference)
value String A JSON formatted string with the user's raw data
errorMessage String The readable error message

Example:

listenerId = SDKFirebaseAuthentication_SignInWithProvider("apple.com");

In the code above we attempt to sign in the current user using the "apple.com" provider (see Apple Authentication for more information on this authentication method). The function call will then return a listener ID (listenerId) that can be used inside a Social Async Event.

if (async_load[? "id"] == listenerId)
{
    if (async_load[? "status"] == 200)
    {
        show_debug_message("User signed in successfully!");
    }
    else
    {
        show_debug_message(async_load[? "errorMessage"]);
    }
}

The code above matches the response against the correct event listener id, checks for a status value of 200 meaning that it was successful and logs the result of the task.