Skip to main content

Set up Garena as an identity provider

The channel ID that Player Network assigned for Garena login is 10, with the channel definition for Unity as INTLChannel.Garena and the channel definition for Unreal Engine as EINTLLoginChannel::kChannelGarena. Player Network supports Garena login on the following platforms:

Garena SDK integrates many third-party SDKs, including many login SDKs. These login channels are provided as sub-channels of Garena in Player Network SDK.

After Player Network SDK version 1.16,Player Network SDK will switch Garena enviroment based on INTLConfig.ini INTL_URL property. Garena will be in test enviroment when Player Network SDK is in test/dev/debug enviroment, and Garena will be in production enviroment when Player Network SDK is in other enviroments.

Currently, the Player Network SDK supported Garena sub-channels include:

  • Android: Guest, Garena, Facebook, Google
  • iOS: Guest, Garena, Facebook, Apple, Google
  • Windows: Garena, Facebook, Google, Apple

Link

Based on the sub-channel of the current logged-in Garena account, there are two types of linking: guest linking, and platform account linking.

  1. Guest linking
    After logging in through the Guest sub-channel of Garena, the guest account can be linked to other Garena sub-channels.

  2. Platform account linking
    After logging in through the non-Guest sub-channel of Garena, the logged-in account can be used as the primary account to link other sub-channel accounts. Before linking, call Request Platform Linking Info to check the available platforms for linking.
    The account linked to the primary account is the secondary account. After linking, if the user logs in with a secondary account, Garena will return the uid and token of the primary account it is linked to.

Reset Garena guest

After linking the Garena guest account successfully, the game needs to call the interface to reset the data of the Garena guest account.

If the guest account is not reset after successful linking, the guest account login will return 2203/1204 (iOS) or 2019 (Android) error code, leading to the login failure for the guest account.

Code sample

// Add callback
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
INTLAPI.AddExtendResultObserver(OnExtendEvent);
}

// Remove Callback
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
INTLAPI.RemoveExtendResultObserver(OnExtendEvent);
}

public void OnAuthResultEvent(INTLAuthResult ret)
{
if (ret.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
if(ret.Channel.Equals(INTLChannel.Garena) && ret.RetCode == INTLErrorCode.SUCCESS)
{
// In the AuthResult callback, invoke resetGuest straightaway if the method is bind, the channel is Garena and the return code is success
INTLAPI.ExtendInvoke(INTLChannel.Garena, "resetGuest", "");
}
}
}

public void OnExtendEvent(INTLExtendResult ret)
{
// Extend callback
}

Request Platform Linking Info

After invoking RequestPlatformBindingInfo, bounded_accounts and available_platforms will be returned as a JSON string in the ret_msg field of ExtendResult. The structure of the JSON string is as follows:

{
"bounded_accounts": [
{
"platform": "Apple",
"create_time": 1627893394,
"uid": 133604802,
"user_info": {
"nickname": "intl",
"gender": 0,
"icon": "http://image.png"
}
}
],
"available_platforms": [
"Garena"
],
"primary_platform": "Apple"
}

Possible values for gender: 0 = Unknown, 1 = Male, 2 = Female.

Before platform account linking, use this method to check available_platforms, and use the platform name as a sub-channel to link.

Code sample

// invoke function
INTLAPI.ExtendInvoke(INTLChannel.Garena, "requestPlatformBindingInfo", "");

public void OnExtendEvent(INTLExtendResult ret)
{
// callback
}