Skip to main content

Web

The purpose of this article is to describe how to set up Garena authentication so that your web pages can log in through the Garena channel using the Player Network login authentication service.

Prerequisites

1. Setting up the Garena application

Contact the Garena team at:

  1. Activate the app and get the app ID and other relevant 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) Turn on APP_PLATFORM_BIND to enable platform account binding for Garena.
  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 information about integrating other third-party Channels with the SDK, see JavaScript SDK.

Step 1: Introduce JavaScript SDK

caution

During project integration testing, import the debugging SDK package, which is intended only for integration testing.For project launch, the official SDK package must be imported.

Currently, both npm package method and CDN method are supported.

$ npm install @intlsdk/account-api

Step 2: Use SDK

caution

During integration testing, set env to test environment; when the project goes live, set env to the corresponding official environment.

const accountApi = new IntlgameAccountApi({
env: "test", // SDK environment
gameID: 11,
});
ParametersTypeDescriptionRemarks
envstringSDK environment
For more information, see Retrieve cluster information.
Required
gameIDnumberPlayer Network unique game IDRequired

Step 3: Implement Web 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);
});