Skip to main content

Android

This article aims to introduce how to set up X authentication so your game can use the Player Network 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 address to register your account, as this can improve the success rate of future applications.

Follow the instructions on the X developer website to register a team developer account or a personal developer account.Once you have a developer account, you can create an application on the Developer Portal.

  1. Create a new project.

    Image: Create X project

  2. Choose a use case.Click Next.

    Image: X project use case

  3. Enter the project description.Click Next.

    Image: X project description

  4. Select the application environment.Click Save.

    Image: X application environment

  5. Enter the 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.

Important

This page will not be displayed again, so be sure to save this information.

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 as the application type.

Image: X OAuth 9. Select Read And Write in application permissions.

Image: X app permissions 10. Enter the test and production environment URLs for the callback URL.You will be redirected 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.

Applicable for Player Network SDK V1.15 and earlier versions

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

Applicable for Player Network SDK V1.16 and later versions

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 X SDK login in INTLConfig.ini, please add the following callback URLs:

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

Replace {API Key} with your game's API Key, excluding the curly brackets .

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. Download the SDK.
  3. Integrate SDK.
  4. Add X as a login authentication method for your business in the Player Network Console.

Step 1: Configure the SDK for X login

  1. Open your project's INTLConfig.ini file:

    INTLConfig.ini
    [INTL environment]
    # WARNING: You should change this URL to the production environment when you release your game.
    INTL_URL = https://test.intlgame.com
    GAME_ID = {INTL_GAME_ID}
    SDK_KEY = {INTL_SDK_KEY}
    [INTL Log]
    LOG_LEVEL = 1
    LOG_CONSOLE_OUTPUT_ENABLE = 1
    LOG_FILE_OUTPUT_ENABLE = 1
    LOG_ENCRYPT_ENABLE = 0
    LOG_COMPRESS_ENABLE = 0
    [Android LifeCycle]
    LIFECYCLE = Twitter
    [X]
    TWITTER_CONSUMER_KEY = {INTL_TWITTER_CONSUMER_KEY}
    TWITTER_CONSUMER_SECRET = {INTL_TWITTER_CONSUMER_SECRET}
    • Set the SDK backend environment to INTL_URL = https://test.intlgame.com.
    • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the values of GAME_ID and SDK_KEY assigned by the Player Network Console.
    • Set LOG_LEVEL = 1, LOG_CONSOLE_OUTPUT_ENABLE = 1, LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0, and LOG_COMPRESS_ENABLE = 0 to output console logs and log files without encryption or compression.
    • Add Twitter to the LIFECYCLE.For more information, see SDK environment.
    • Replace {INTL_TWITTER_CONSUMER_KEY} and {INTL_TWITTER_CONSUMER_SECRET} with the X API key and API Key Secret.

Step 2: Add X login

After the user logs in, select the X channel to bind.If the user uses an already bound X account, a server error will be prompted.Calling the Bind interface again will require the user to log in to X again.

  1. Register login-related callbacks.
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}

// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}

// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

string methodTag = "";
if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
{
methodTag = "Login";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
{
methodTag = "Bind";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
{
methodTag = "GetAuthResult";
}
}
  1. Call the AutoLogin interface to log in automatically.
INTLAPI.AutoLogin();
  1. If automatic login fails, call the Login interface to allow players to log in manually.
INTLAPI.Login(INTLChannel.Twitter); 
  1. Synchronize client authentication status with the game backend and wait for the final verification result.

[Optional] Set email permissions

To obtain the player's email when logging in through X, you need to set the corresponding permission first. Once enabled, email will be returned in the ChannelInfo of the AuthResult.

  • For compliance reasons, you can mask the returned email for specific sources. If needed, please contact Player Network assistant to enable it.
  • You can report base64(sha256(email)) after hashing the email in the backend pipeline logs. If needed, please contact Player Network assistant to enable it.
  • Can be used to verify player information or if the binding list includes email information. If needed, please contact Player Network assistant to enable it.
  1. In User authentication settings on the X Developer Platform, check Request email from users.

    Image: OAUTH1.OA SETTINGS
  2. Enable the email return function in the Player Network Console by setting return_email to YES. For detailed steps, see Third-party channel configuration.

Step 3: Acceptance of the login function

Search for the keyword "AuthResult" in the Player Network SDK logs to confirm the channel name and OpenID are returned correctly.If correct, it means the integration and configuration are successful and the login function has been successfully added.

If you encounter problems during integration, refer to FAQs.