Skip to main content

Web

This article guides you through setting up Garena as an identity provider, enabling your website 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. Add Garena as an authentication method for your project on Player Network Console.
note

For more details about integrating the SDK for other third-party channels, see JavaScript SDK.

Step 1: Install the JavaScript SDK

caution

Install the SDK package from the production environment when launching the game. The SDK package from the test environment is only used for integration testing.

Install the JavaScript SDK from npm or CDN.

$ npm install @intlsdk/account-api

Step 2: Instantiate the SDK

caution

Set env to the test environment during the integration testing and env to the corresponding production environment when launching the game.

const accountApi = new IntlgameAccountApi({
env: "test", // SDK environment
gameID: 11,
});
ParameterTypeDescriptionRemark
envstringSDK environment
For more information, see Retrieve cluster information.
Required
gameIDnumberUnique game ID assigned by Player NetworkRequired

Step 3: Implement Garena login

After instantiating the accountApi component, call the thirdAuthorize method to request the access token from Garena.

accountApi.thirdAuthorize({
third_type: 'garena',
}).then(
(res) => {
console.log(res);
});

With the Garena token returned, call the intlAuthorize method to get the Player Network SDK OpenID and token to log in to your website.

accountApi.intlAuthorize({
third_type: 'garena',
channel_info: {
token: "EAAI2lTrXAZBwBAC"
garena_sns_openid: "EAAI2lTrXAZBwBAC"
garena_sns_token: "EAAI2lTrXAZBwBAC"
}
}).then(
(res) => {
console.log(res);
});

Call the intlLogout method to log out from your website.

accountApi.intlLogout({
token: '4567xsdfsd',
openid: 'xxxxxxxx',
channel_id: 10,
}).then(
(res) => {
console.log(res);
});