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.

    Image: Create X project

  2. Select a use case.Click Next.

    Image: X project use case

  3. Enter a project description.Click Next.

    Image: X project description

  4. Select application environment.Click Save.

    Image: X application environment

  5. Enter your application name.Click Save.

    Image: X app name

  6. After creating the application, obtain the API key and API secret key.Store this information.Click App Settings.

    Image: X API key and API secret key

  7. Click Set up.

    Image: X setup

  8. Enable OAuth2.0 and OAuth1.0a.Select Web App under application type.

    Image: X OAuth

  9. Select Read And Write under application permissions.

    Image: X app permissions

  10. Enter the URL for both the test environment and production environment as the callback URL.You will be directed to the official website of the game.Click Save.

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

When TWITTER_CONSUMER_USE_SDK is set to 1, to use the X SDK login specified in INTLConfig.ini, please add the following callback URLs:

twittersdk://
twitterkit-{API Key}://

{API Key} needs to be replaced with the game's API Key, without the curly braces .

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);
});