Skip to main content

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:

  1. Activate the app and obtain the app ID and other related information.
  2. Configure the callback URL for Garena login on the developer platform:
    • https://test-common-web.intlgame.com/jssdk/garenalogincallback.html
    • https://common-web.intlgame.com/jssdk/garenalogincallback.html
  3. [Optional] Enable APP_PLATFORM_BIND, to use Garena's platform account linking.
  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add Garena as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK

Open the project's INTLConfig.ini:

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 the GAME_ID and SDK_KEY assigned by Player Network Console.
  • Set LOG_LEVEL = 1, LOG_CONSOLE_OUTPUT_ENABLE = 1, LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0, and LOG_COMPRESS_ENABLE = 0 to output console logs and log files without encrypting or compressing the output.
  • Set the value of GARENA_WEBVIEW_LOGIN_ENABLE. The default value is 1, indicating that the Windows platform uses the WebView for login. If users set the value to 0, the Windows platform uses system browser for login.
caution

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

  1. Add an observer to handle authentication callbacks.

    // 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";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. If auto-login fails, call the Login method to prompt users to manually log in through the Garena official website.

    note

    All sub-channels configured in the Garena developer backend are supported on Windows, and are passed in the appendix of the ExtraJson field. 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=1 or leave ExtraJson empty
    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 platforms

    Garena Login permission parameter 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:

    Image: Garena Permission

  4. 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.