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
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add Square Enix as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK
In the
AndroidManifest
file, add required permissions. Square Enix requires access to the network.<uses-permission android:name="android.permission.INTERNET"/>
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.
- Replace
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.
Add an observer to handle authentication callbacks.
- Unity
- Unreal Engine
// 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";
}
}C++ Event Handling (above v1.15)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Unreal Event Handling
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Call the
AutoLogin
method.- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
Call the
Login
method to ask for user input if auto-login fails.- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.SquareEnix, "", "");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelSquareEnix);
Sync client authentication state with the game's backend and wait for the final authentication result.
Logout Function
Currently, the logout function only exits the login state, and does not clear the UUID. Games need to use resetUuid
to clear it.
- Unity
- Unreal Engine
INTLAPI.Logout(INTLChannel.SquareEnix);
UINTLSDKAPI::Logout(EINTLLoginChannel::kChannelSquareEnix);
Step 3: Test the login function
- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.SquareEnix, "", "{\"se_login_only\":true}");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelSquareEnix, "", "{\"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": {}
}
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:
- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.SquareEnix, "", "{\"se_register\":true}");
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelSquareEnix, "", "{\"se_register\":true}");
Other Functions
Link Function
- Unity
- Unreal Engine
INTLAPI::ExtendInvoke(INTLChannel.SquareEnix, "bind", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "bind", "");
For more information on the linking process, see Linking Docs.
Credential Transfer Function
- Unity
- Unreal Engine
INTLAPI::ExtendInvoke(INTLChannel.SquareEnix, "takeover", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "takeover", "");
For more information on the credential transfer process, see Credential Transfer Docs.
User Info Acquisition Function
- Unity
- Unreal Engine
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getSeUserInfo", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "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
- Unity
- Unreal Engine
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getSeUserId", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "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
- Unity
- Unreal Engine
string extraJson = "{\"world_id\":\"@self\"}";
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "createSeWorld", extraJson);
FString extraJson = "{\"world_id\":\"@self\"}";
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "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
- Unity
- Unreal Engine
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix,"getSeNativeSessionId", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "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)
- Unity
- Unreal Engine
string uuid = INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getCurrentUuid", "");
FString uuid = UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "getCurrentUuid", "");
Get UUID Earlier Login Status Information (Sync)
- Unity
- Unreal Engine
string loggedIn = INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "getUuidLoginStatus", "");
FString loggedIn = UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "getUuidLoginStatus", "");
Current UUID Login Data Deletion Function
- Unity
- Unreal Engine
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "resetUuid", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "resetUuid", "");
Update SeSession Function
- Unity
- Unreal Engine
INTLAPI.ExtendInvoke(INTLChannel.SquareEnix, "updateSeSession", "");
UINTLSDKAPI::ExtendInvoke(EINTLLoginChannel::kChannelSquareEnix, "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.
*/