Android
After uninstalling the game on your Android device, your Garena guest account will be lost.It is recommended that the game encourage visitor players to bind their visitor accounts to their platform accounts as soon as possible to avoid accidental loss of visitor accounts and to enhance the social attributes of the game.
The purpose of this article is to describe how to set up Garena authentication so that your game can be logged in through the Garena channel using the Player Network login authentication service.
Prerequisites
1. Setting up the Garena application
Contact the Garena team to activate the app and obtain an app ID and other relevant information.
For Player Network SDK V1.24 and later, you will also need to contact the Garena team to obtain the Garena_Username and Garena_Password for the Maven repository associated with the Garena SDK.
To use Garena's platform account bindings, request that Garena enable APP_PLATFORM_BIND.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download SDK.
- Integrate the SDK.
- Add Garena as an authentication method for your project on Player Network Console.
Step 1:Configure SDK for Garena Login
-
Open the INTLConfig.ini file.
INTLConfig.ini[INTL environment]
# WARNING: You should change this URL to the production environment when you release your game.
INTL_URL = https://intlsdk-new-test.iegg.garena.com
GAME_ID = {INTL_GAME_ID}
SDK_KEY = {INTL_SDK_KEY}
[INTL Log]
LOG_LEVEL = 1
LOG_CONSOLE_OUTPUT_ENABLE = 1
LOG_FILE_OUTPUT_ENABLE = 1
LOG_ENCRYPT_ENABLE = 0
LOG_COMPRESS_ENABLE = 0
[Android LifeCycle]
LIFECYCLE = Garena
[Garena Channel Configurations]
GARENA_APP_SDK_ASSIGN_ID = {INTL_GARENA_APP_SDK_ASSIGN_ID}
GARENA_APP_SDK_KEY = {INTL_APP_KEY}- Set the Player Network SDK authentication domain to
INTL_URL = https://intlsdk-new-test.iegg.garena.comand contact the Garena team for details and an official environment URL. - Replace
{INTL_GAME_ID}and{INTL_SDK_KEY}with theGAME_IDandSDK_KEYassigned by the Player Network Console. - Set
LOG_LEVEL = 1,LOG_CONSOLE_OUTPUT_ENABLE = 1,LOG_FILE_OUTPUT_ENABLE = 1,LOG_ENCRYPT_ENABLE = 0andLOG_COMPRESS_ENABLE = 0to output console logs and log files without encrypting or compressing the output without encrypting or compressing the output. - Add Garena to
LIFECYCLE.For more information, please see SDK Environment. - Replace
{INTL_GARENA_APP_SDK_ASSIGN_ID}with the registered Garena App ID. - Replace
{INTL_APP_KEY}with the registered Garena App Key.
- Set the Player Network SDK authentication domain to
-
Define
manifestPlaceholdersin the gradle file, replacing{INTL_GARENA_APP_SDK_ASSIGN_ID},{INTL_FACEBOOK_APP_ID}and{INTL_GOOGLE_CLIENT_ID}with the appropriate values for the application.- Accessing Player Network SDK V1.22 and later also requires replacing
{INTL_FACEBOOK_CLIENT_TOKEN}with the value ofFACEBOOK_CLIENT_TOKEN. - Accessing Player Network SDK V1.24 and later also requires replacing
{INTL_GARENA_MAVEN_USERNAME}and{INTL_GARENA_MAVEN_PASSWORD}with the valuesGarena_UsernameandGarena_Password.
- Accessing Player Network SDK V1.22 and later also requires replacing
- Unity
- Unreal Engine
For Unity version 2022, edit settingsTemplate.gradle.
For Unity 2019/2020/2021 versions, please edit baseProjectTemplate.gradle.
For Unity 2018 and earlier, edit mainTemplate.gradle.
android {
defaultConfig {
manifestPlaceholders = [
"GARENA_APP_ID":"{INTL_GARENA_APP_SDK_ASSIGN_ID}",
"FACEBOOK_APPID":"{INTL_FACEBOOK_APP_ID}",
"GOOGLE_CLIENT_ID":"{INTL_GOOGLE_CLIENT_KEY_ANDROID}",
"FACEBOOK_CLIENT_TOKEN":"{INTL_FACEBOOK_CLIENT_TOKEN}", // V1.22 added
"Garena_Username":"{INTL_GARENA_MAVEN_USERNAME}", // V1.24 added
"Garena_Password":"{INTL_GARENA_MAVEN_PASSWORD}", // V1.24 added
]
}
}
For Player Network SDK V1.17 and higher, edit INTLConfig_APL.xml.
For Player Network SDK V1.16.04 and earlier versions, please edit INTLCore_UPL.xml.
<buildGradleAdditions>
<insert>
<![CDATA[
android{
defaultConfig {
manifestPlaceholders += [
"GARENA_APP_ID":"{INTL_GARENA_APP_SDK_ASSIGN_ID}",
"FACEBOOK_APPID":"{INTL_FACEBOOK_APP_ID}",
"GOOGLE_CLIENT_ID":"{INTL_GOOGLE_CLIENT_KEY_ANDROID}",
"FACEBOOK_CLIENT_TOKEN":"{INTL_FACEBOOK_CLIENT_TOKEN}", // V1.22 added
"Garena_Username":"{INTL_GARENA_MAVEN_USERNAME}", // V1.24 added
"Garena_Password":"{INTL_GARENA_MAVEN_PASSWORD}", // V1.24 added
]
}
}]]>
</insert>
</buildGradleAdditions>
- Declare the permissions in the
AndroidManifest.xmlfile according to the following code.
WRITE_EXTERNAL_STORAGE is a sensitive permission.
<manifest ... >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
...
</manifest>
-
For Unreal Engine, update the Garena billing repository for Player Network SDK V1.13 and later to 4.0.0
-
If using Unreal Engine 4.25,
- Download GooglePlayStoreHelper.java.Then replace the
{UE_PATH}/Engine/Plugins/Online/Android/OnlineSubsystemGooglePlay/Source/Java/com/epicgames/ue4/GooglePlayStoreHelper.javafile. - Download OnlineSubsystemGooglePlay_UPL.xml.Then replace the
{UE_PATH}/Engine/Plugins/Online/Android/OnlineSubsystemGooglePlay/Source/OnlineSubsystemGooglePlay_UPL.xmlfile.
- Download GooglePlayStoreHelper.java.Then replace the
-
If using Unreal Engine 4.26 or later,
- Download GooglePlayStoreHelper.java.Then replace the
{UE_PATH}/Engine/Plugins/Online/Android/OnlineSubsystemGooglePlay/Source/Java/BillingApiV2/com/epicgames/ue4/GooglePlayStoreHelper. javafile. - Change the billing repository version in
{UE_PATH}/Engine/Plugins/Online/Android/OnlineSubsystemGooglePlay/Source/OnlineSubsystemGooglePlay_UPL.xmlto4.0.0.

- Download GooglePlayStoreHelper.java.Then replace the
-
Step 2:Add Garena Login
- Register login-related callbacks.
- Unity
- Unreal Engine
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}
// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}
// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult AuthResult)
{
Debug.Log($"MethodID: {AuthResult.MethodId}");
string methodTag = "";
switch (AuthResult.MethodId)
{
case (int)INTLMethodID.INTL_AUTH_LOGIN:
methodTag = "Login";
break;
case (int)INTLMethodID.INTL_AUTH_BIND:
methodTag = "Bind";
break;
case (int)INTLMethodID.INTL_AUTH_AUTOLOGIN:
methodTag = "AutoLogin";
break;
case (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO:
methodTag = "QueryUserInfo";
break;
case (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT:
methodTag = "GetAuthResult";
break;
}
}
C++ Event Handling Method (V1.15 and above)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}
Unreal event handling method
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}
- Call the
AutoLogininterface to log in automatically.
- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
- Calls the
Logininterface when auto-login fails, causing the player to log in manually.
Currently, the Player Network SDK supports logging into the Android Garena sub-channels Guest, Garena, Facebook, and Google.See which sub-channel is currently being used for login by examining the sub-channel name returned in the ExtraJson field of the AuthResult.For example, {"subChannel": "Facebook"}".
Log in to Garena's Facebook subchannel at:
- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.Garena, "", "{\"subChannel\":\"Facebook\"}");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"subChannel\":\"Facebook\"}");
- If the application is installed, open the application login, otherwise open the web login.
- The Garena login
permissionparameter is different from other channels.The user needs to enter numbers in string format.For example, "2" or "4".Permissions are defined as follows:

- Synchronize client authentication status with the game backend and wait for the final verification result.
Step 3: Acceptance testing for login functionality
Search for the keyword "AuthResult" in the Player Network SDK logs to confirm whether the channel name and OpenID are returned correctly.If correct, it means the integration configuration is successful, and login functionality has been successfully added.
If you encounter issues during the integration process, see FAQs.
Bindings
Android will lose your Garena guest account after uninstalling the game.It is recommended that the games encourage visitors to bind to the platform as early as possible to avoid accidental account loss, as well as to enhance the social attributes.
Due to Garena's restrictions:
- If you have previously used a Facebook login, you cannot use it as a sub-channel for a Garena login.Otherwise, the error code
1013is returned. - Once you have successfully tied up your Garena account, you cannot tie it up again.
When the Bind interface is called, the sub-channel application (or web page) is opened to perform login authentication.After successful authentication, Player Network SDK will bind the sub-channel's account to the visitor's account.
- Unity
- Unreal Engine
// Log in as guest
INTLAPI.Login(INTLChannel.Garena, "", "{\"subChannel\":\"Guest\"}");
// Bind Logic
INTLAPI.Bind(INTLChannel.Garena, "", "{\"subChannel\":\"Facebook\"}");
// Log in as guest
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"subChannel\":\"Guest\"}");
// Bind Logic
UINTLSDKAPI::Bind(EINTLLoginChannel::kChannelGarena, "", "{\"subChannel\":\"Facebook\"}");
If binding a guest account to Garena fails, the game must invoke Garena's guest login again.
After calling the Bind interface, the Garena SDK session is set to the newly bound channel (with visitor login status), regardless of the binding result.If the Bind interface is called again, the binding will fail due to a session validation failure.Therefore, it is recommended that Visitor Login be called again to return to the normal Visitor Login state.
If you have trouble logging in through Garena, see Garena FAQs.