Skip to main content

Web

This document is intended to introduce how to set up X authentication so that your website can use Player Network's login authentication service to log in through the X channel.

Prerequisites

1. Set up your game on the X developer website

1. Create X application

tip

It is recommended to use a Tencent email to register your account to improve the success rate in later applications.

Follow the prompts on the X Developer Website to register as a team developer or individual developer.With a developer account, you can create applications on the Developer Portal.

  1. Create a new project as instructed.

    Image: Create X project

  2. Click the application you created.

    Image: X app

  3. Click Regenerate to obtain the API Key and API Secret Key.

Important

This page will not be displayed again. Please make sure to save this information.

Image: X API key and API secret key Image: X API key and API secret key

  1. Click Set up.

    Image: X setup

  2. Select Read And Write.

    Image: X app permissions

  3. Select Web App under application type.

    Image: X OAuth

  4. Add the test environment and production environment URLs as the callback URL.You will be directed to the official website of the game.Click Save Changes.

caution

If the game is already live, you cannot delete the existing callback URL, only add new ones.

Supported for Player Network SDK V1.15 and earlier versions on Android/iOS platforms.

https://image.intlgame.com/v2/test/jssdk/twitterlogincallback.html
https://image.intlgame.com/v2/release/jssdk/twitterlogincallback.html

Supported for Player Network SDK V1.16 and higher versions on Android/iOS platforms and Windows platform.

https://test-common-web.intlgame.com/jssdk/twitterlogincallback.html
https://common-web.intlgame.com/jssdk/twitterlogincallback.html

Image: X callback URLs

2. Retrieve application information

You need the X App ID and secret to add X login channel in Player Network.

Image: X app information

  1. Go to the Player Network Console to create a new project for your game or join an existing one.
  2. Add X as a login authentication method for your business in the Player Network Console.
info

For more information on integrating other third-party channels into SDK, please see JavaScript SDK.

Step 1: Import the JavaScript SDK

Both npm package and CDN methods are supported.

$ npm install @intlsdk/account-api

Step 2: Use the SDK

Important

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

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

Step 3: Implement web login

After instantiating the accountApi component, call the thirdAuthorize interface to request the access token and access secret for the X channel.

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

After X returns the access token and key, call the intlAuthorize API to obtain the Player Network SDK OpenID and token to log in to the website.

accountApi.intlAuthorize({
third_type: 'twitter',
channel_info: {
oauth_token: "EAAI2lTrXAZBwBAC"
oauth_secret: "xxxx"
}
}).then(
(res) => {
console.log(res);
});

Call the intlLogout interface to log out from the website.

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