Skip to main content

Android

This article guides you through setting up Square Enix as an identity provider, enabling your Android game to access Player Network authentication services.

Prerequisites

1. Set up the Square Enix app

Contact the Square Enix team to activate your app, then obtain the タイトルID (SE Game ID), Consumer Key, and Consumer Secret from Square Enix Bridge.

Get app info

Image: Square Enix SE 1

Image: Square Enix SE 2

Image: Square Enix SE 3

Image: Square Enix SE 4

  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add Square Enix as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK

  1. In the AndroidManifest file, add required permissions. Square Enix requires access to the network.

    <uses-permission android:name="android.permission.INTERNET"/>
  2. Open the project's INTLConfig.ini:

    [SquareEnix]
    SQUARE_ENIX_APP_ID = {INTL_SQUARE_ENIX_APP_ID}
    SQUARE_ENIX_CONSUMER_KEY = {INTL_SQUARE_ENIX_CONSUMER_KEY}
    SQUARE_ENIX_CONSUMER_SECRET = {INTL_SQUARE_ENIX_CONSUMER_SECRET}
    SQUARE_ENIX_TEST = 0
    • Replace {INTL_SQUARE_ENIX_APP_ID} with the Square Enix App ID of the application submitted by the game team.
    • Replace {INTL_SQUARE_ENIX_CONSUMER_KEY} with the Square Enix Consumer Key of the application submitted by the game team.
    • Replace {INTL_SQUARE_ENIX_CONSUMER_SECRET} with the Square Enix Consumer Secret of the application submitted by the game team.
    • SQUARE_ENIX_TEST: Used to determine if it is the Square Enix test environment; 0: production environment, 1: test environment; 0 is default.

Step 2: Add Square Enix login

The people.create API will be called automatically for registration during the first time the login API is called.
For more information, see Sign up or Login from the Square Enix Bridge Developer Center.

  1. Add an observer to handle authentication 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";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

    INTLAPI.Login(INTLChannel.SquareEnix, "", "");
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

Logout Function

note

Currently, the logout function only exits the login state, and does not clear the UUID. Games need to use resetUuid to clear it.

INTLAPI.Logout(INTLChannel.SquareEnix);

Step 3: Test the login function

INTLAPI.Login(INTLChannel.SquareEnix, "", "{\"se_login_only\":true}");
  • If the login is successful, the returned result is the same as the normal login result.
  • If the login is unsuccessful, check the specific error code and error message: RetCode, RetMsg, ThirdCode, ThirdMsg.

Return result example (success):

{
"OpenId": "xxxxxxxxxxxxxxx",
"Token": "xxxxxxxxxxxxxxx",
"TokenExpire": 1641044623,
"FirstLogin": 0,
"UserName": "",
"Gender": 0,
"Birthdate": "",
"PictureUrl": "",
"Pf": "xxxxxxxxxxxxx",
"PfKey": "xxxxxxxxxxxxx",
"NeedRealNameAuth": false,
"ChannelID": 32,
"Channel": "SquareEnix",
"ChannelInfo": {
"se_sessionid": "xxxxxxxxxxxxxxx",
"expire_ts": 1641044623
},
"ConfirmCode": "",
"BindList": "",
"MethodId": 102,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 0,
"ThirdMsg": "success",
"ExtraJson": {}
}
info

If the device is redirected by other devices after a successful login, and the login or automatic login process is executed, an error code whose ThirdCode is 1276 will be returned, indicating that the current login status is invalid.

The login in this scenario must use the following method:

INTLAPI.Login(INTLChannel.SquareEnix, "", "{\"se_register\":true}");

Other Functions

Link Function

INTLAPI::ExtendInvoke(INTLChannel.SquareEnix, "bind", "");

For more information on the linking process, see Linking Docs.

Credential Transfer Function

INTLAPI::ExtendInvoke(INTLChannel.SquareEnix, "takeover", "");

For more information on the credential transfer process, see Credential Transfer Docs.

User Info Acquisition Function

INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getSeUserInfo", "");

Return result example:

{
"Channel": "SquareEnix",
"ExtendMethodName": "getSeUserInfo",
"MethodId": 1301,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 1,
"ThirdMsg": "",
"ExtraJson": {
"uuid": "576091342997165636789245472976025261",
"se_user_info": "{\"androidRegistrationId\":null,\"iosDeviceToken\":null,\"channel\":null,\"deviceType\":2,
\"nativeTagName\":\"apr1A6XN7jnGf\",\"nativeUserId\":18235236,\"nickName\":null,\"thumbnailUrl\":null,
\"gameId\":470,\"inviteNativeUserId\":null,\"userId\":null,\"cesaLimitAge\":null,\"sex\":null,
\"fcmRegistrationId\":null,\"tagName\":null,\"birthYearMonth\":null,\"introduction\":null,\"userRank\":0}"
}
}
// Parse "se_user_info" in the ExtraJson field

User ID Acquisition Function

INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getSeUserId", "");

Return result example:

{
"Channel": "SquareEnix",
"ExtendMethodName": "getNativeUserID",
"MethodId": 1301,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 1,
"ThirdMsg": "",
"ExtraJson": {
"se_user_id": 18235236
}
}
// Parse "se_user_id"

Server Creation Function

string extraJson =  "{\"world_id\":\"@self\"}";
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "createSeWorld", extraJson);

The extraJson field should pass the world_id of the created world. To use defaults, pass @self.

Return result example (success):

{
"Channel": "SquareEnix",
"ExtendMethodName": "createSeWorld",
"MethodId": 1301,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 1,
"ThirdMsg": "",
"ExtraJson": {}
}

Return result example (failure):

{
"Channel": "SquareEnix",
"ExtendMethodName": "createSeWorld",
"MethodId": 1301,
"RetCode": 5,
"RetMsg": "Server error",
"ThirdCode": 1277,
"ThirdMsg": "world has been created, se response 404: [E2001](67) ModelCode: DAO-493014",
"ExtraJson": {}
}
// ThirdCode is the error code reported
// ThirdMsg is the error reason

Channel SessionId Acquisition Function

INTLAPI.ExtendInvoke(INTLChannel.SquareEnix,"getSeNativeSessionId", "");

Return result example:

{
"Channel": "SquareEnix",
"ExtendMethodName": "getCachedNativeSessionId",
"MethodId": 1301,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 1,
"ThirdMsg": "",
"ExtraJson": {
"se_session_id": "034991a20e2f150577be4f93b8d471a1"
}
}
// Parse "se_session_id"

Get Current UUID (Sync)

string uuid = INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getCurrentUuid", "");

Get UUID Earlier Login Status Information (Sync)

string loggedIn = INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getUuidLoginStatus", "");

Current UUID Login Data Deletion Function

INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "resetUuid", "");

Update SeSession Function

INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "updateSeSession", "");

Return result example:

{
"OpenId": "xxxxxxxxxxxxxxx",
"Token": "xxxxxxxxxxxxxxx",
"TokenExpire": 1641649788,
"FirstLogin": 0,
"UserName": "",
"Gender": 0,
"Birthdate": "",
"PictureUrl": "",
"Pf": "xxxxxxxxxxxxxxx",
"PfKey": "xxxxxxxxxxxxxxx",
"NeedRealNameAuth": false,
"ChannelID": 32,
"Channel": "SquareEnix",
"ChannelInfo": {
"expire_ts": 1641649788,
"se_sessionid": "xxxxxxxxxxxxxxx",
"is_refresh": 1
},
"ConfirmCode": "",
"BindList": "",
"MethodId": 101,
"RetCode": 0,
"RetMsg": "Success",
"ThirdCode": 0,
"ThirdMsg": "user is logged in.",
"ExtraJson": {}
}
/*
Refreshing the session interface follows the same process as automatic login.
The is_refresh in ChannelInfo is 1, which means that the refresh session interface returns,
and se_sessionid is the corresponding updated session ID.
*/