Windows
This article guides you through setting up Garena as an identity provider, enabling your Windows game to access Player Network authentication services.
Prerequisites
1. Set up the Garena app
Contact the Garena team to:
- Activate the app and obtain the app ID and other related information.
- Configure the callback URL for Garena login in the developer platform:
https://test-common-web.intlgame.com/jssdk/garenalogincallback.htmlhttps://common-web.intlgame.com/jssdk/garenalogincallback.html
- [Optional] Enable
APP_PLATFORM_BIND, to use Garena's platform account linking.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add Garena as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK
Open the project's 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
[Garena Channel Configurations]
GARENA_WEBVIEW_LOGIN_ENABLE = 1
- Set the Player Network SDK authentication domain to
INTL_URL = https://intlsdk-new-test.iegg.garena.com(contact the Garena team to provide). - Replace
{INTL_GAME_ID}and{INTL_SDK_KEY}with theGAME_IDandSDK_KEYassigned by Player Network Console. - Set
LOG_LEVEL = 1,LOG_CONSOLE_OUTPUT_ENABLE = 1,LOG_FILE_OUTPUT_ENABLE = 1,LOG_ENCRYPT_ENABLE = 0, andLOG_COMPRESS_ENABLE = 0to output console logs and log files without encrypting or compressing the output. - Set the value of
GARENA_WEBVIEW_LOGIN_ENABLE. The default value is1, indicating that the Windows platform uses the WebView for login. If users set the value to0, the Windows platform uses system browser for login.
If GARENA_WEBVIEW_LOGIN_ENABLE in INTLConfig is set to 1, integration of the INTLWebView plugin is required, otherwise the login will not be successful.
Step 2: Add Garena login
-
Add an observer to handle authentication 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 ret)
{
Debug.Log($"MethodID: {ret.MethodId}");
string methodTag = "";
if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
{
methodTag = "Login";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
methodTag = "Bind";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
{
methodTag = "GetAuthResult";
}
}C++ Event Handling (above v1.15)
//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
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
} -
Call the
AutoLoginmethod.- Unity
- Unreal Engine
INTLAPI.AutoLogin();UINTLSDKAPI::AutoLogin(); -
If auto-login fails, call the
Loginmethod to prompt users to manually log in through the Garena official website.noteAll sub-channels configured in the Garena developer backend are supported on Windows, and are passed in the
appendixof theExtraJsonfield. For example,"{\"appendix\":\"platform=1\"}".The Player Network SDK supported Garena sub-channels on Windows are as follows:
- Garena:
platform=1 - Facebook:
platform=3 - Google:
platform=8 - Apple:
platform=10 - All platforms:
all_platforms=1or leaveExtraJsonempty
- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.Garena, "", "{\"appendix\":\"platform=1\"}");// Garena login - Garena (1)
INTLAPI.Login(INTLChannel.Garena, "", "{\"appendix\":\"platform=3\"}");// Garena login - Facebook (3)
INTLAPI.Login(INTLChannel.Garena, "", "{\"appendix\":\"platform=8\"}");// Garena login - Google (8)
INTLAPI.Login(INTLChannel.Garena, "", "{\"appendix\":\"platform=10\"}");// Garena login - Apple (10)
INTLAPI.Login(INTLChannel.Garena, "", "{\"appendix\":\"all_platforms=1\"}");// Garena login - All platforms
INTLAPI.Login(INTLChannel.Garena, "", "");// Garena login - All platformsUINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"appendix\":\"platform=1\"}");// Login Garena - Garena (1)
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"appendix\":\"platform=3\"}");// Login Garena - Facebook (3)
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"appendix\":\"platform=8\"}");// Login Garena - Google (8)
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"appendix\":\"platform=10\"}");// Login Garena - Apple (10)
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "{\"appendix\":\"all_platforms=1\"}");// Login Garena - All platforms
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelGarena, "", "");// Login Garena - All platformsGarena Login
permissionparameter differs from the rest of the channels. Users need to pass in the numeric in string format. For example, "2" or "4". The permissions are defined as follows:
- Garena:
-
Sync client authentication state with the game's backend and wait for the final authentication result.
Step 3: Test the login function
Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.