Skip to main content
Version: 5.15.0

LoginWithTheBackendToken

public BackendReturnObject LoginWithTheBackendToken();

Description

User who logged in before tries to log in using a BACKND AccessToken stored in the device locally.
BACKND SDK's login method requires an unexpired access_token or refresh_token stored in the device.
When the login succeeds, access_token and refresh_token are updated with new ones.

Precautions when implementing token login

The token may expire for various reasons, such as login from another device and changes in the backend.dat file due to an update.
In such cases, a general login is required, as the token login is unavailable.

When using the token login, make sure to configure the code so that the general login is available upon a token login failure.

Example

Synchronous

BackendReturnObject bro = Backend.BMember.LoginWithTheBackendToken();
if(bro.IsSuccess())
{
Debug.Log("Automatic login successful");
}

Asynchronous

Backend.BMember.LoginWithTheBackendToken((callback) => {
if (callback.IsSuccess()) {
Debug.Log("Automatic login successful");
}
});

SendQueue

SendQueue.Enqueue(Backend.BMember.LoginWithTheBackendToken, (callback) => {
if (callback.IsSuccess()) {
Debug.Log("Automatic login successful");
}
});

ReturnCase

Success cases

When login is successful
statusCode : 201
message : Success

Error cases

When the user tries token login but there is no local access token in the device
statusCode : 400
errorCode : accessTokenError
message : accessToken not exist

When attempting in a situation where the token value does not exist, such as no login or reconnecting after logging out
statusCode : 400
errorCode : UndefinedParameterException
message : undefined refresh_token, refresh_token cannot be checked

When the refresh_token expires because the user logged in to another device
statusCode : 401
errorCode : BadUnauthorizedException
message : bad refreshToken, Invalid refreshToken

When the user is blocked
statusCode : 403
errorCode : The reason for blocking entered in the console
message : Forbidden blocked user, Blocked user
code : 403100
errorMessage : 757fe1d0-03af-11ef-bda5-fd24a5f141c1 blocked until 2024-11-29T12:41:19.465Z
errorData : {
uuid : 757fe1d0-03af-11ef-bda5-fd24a5f141c1
nickname : Nickname
blockReason : The reason for blocking entered in the console
blockDate : 2024-11-29T12:41:19.465Z
}

If the user is blocked, you can check the following error data.

  • Code : Unique ID for the error case
  • ErrorMessage : Details of that error
  • ErrorData : Detailed data related to the error (If nickname and blockReason do not exist, data cannot be parsed.)

Error use example

var callback = Backend.BMember.CustomLogin("a0", "a0");

Debug.Log(
if (callback.GetMessage().StartsWith("Forbidden blocked user"))
{
StringBuilder returnString = new StringBuilder();
returnString.Append("StatusCode : ").Append(callback.GetStatusCode()).AppendLine();
returnString.Append("ErrorCode : ").Append(callback.GetErrorCode()).AppendLine();
returnString.Append("Message : ").Append(callback.GetMessage()).AppendLine();

returnString.Append("Code : ").Append(callback.GetCode()).AppendLine();
returnString.Append("ErrorMessage : ").Append(callback.GetErrorMessage()).AppendLine();

returnString.Append("errorData(uuid) : ").Append(callback.GetErrorData()["uuid"].ToString()).AppendLine();

if (callback.GetErrorData().ContainsKey("nickname"))
{
returnString.Append("errorData(nickname) : ").Append(callback.GetErrorData()?["nickname"].ToString()).AppendLine();
}

if (callback.GetErrorData().ContainsKey("blockReason"))
{
returnString.Append("errorData(blockReason) : ").Append(callback.GetErrorData()?["blockReason"].ToString()).AppendLine();
}

returnString.Append("errorData(blockDate) : ").Append(callback.GetErrorData()["blockDate"].ToString()).AppendLine();

Debug.Log(returnString.ToString());
}
)

When the device is blocked
statusCode : 403
errorCode : ForbiddenException
message : Forbidden blocked device, Blocked device
code : 403100
errorMessage : 20240426092307fc5ac478c is blocked
errorData : {
deviceUniqueId : 20240426092307fc5ac478c
}

If the device is blocked, you can check the following error data.

  • Code : Unique ID for the error case
  • ErrorMessage : Details of that error
  • ErrorData : Detailed data related to the error

Error use example

var callback = Backend.BMember.CustomSignUp("a0", "a0");

Debug.Log(
if (callback.IsDeviceBlockError())
{
StringBuilder returnString = new StringBuilder();
returnString.Append("StatusCode : ").Append(callback.GetStatusCode()).AppendLine();
returnString.Append("ErrorCode : ").Append(callback.GetErrorCode()).AppendLine();
returnString.Append("Message : ").Append(callback.GetMessage()).AppendLine();
returnString.Append("Code : ").Append(callback.GetCode()).AppendLine();
returnString.Append("ErrorMessage : ").Append(callback.GetErrorMessage()).AppendLine();
returnString.Append("errorData(deviceUniqueId)").Append(callback.GetErrorData()["deviceUniqueId"].ToString()).AppendLine();
Debug.Log(returnString.ToString());
}
)

When the refresh_token has expired after one year
statusCode: 410
errorCode: GoneResourceException
message : Gone expired refreshToken, refreshToken does not exist.