Skip to main content
Version: 5.11.4

Device Block Error Case

Summary

The procedure for device block error is as follows:

  1. Device error occurs during game use
  2. The access token of the user using the device is deleted
  3. 'bad accesstoken' error occurs for all BACKND method calls
  4. RefreshTheBackendToken or login method is called to reissue an access token
  5. '403 Forbidden blocked device' occurs at the point of reissuing the token or login method

Description

When a user tries to log in using a device registered as a blocked device via BACKND Console, a 403 error occurs.

statusCode : 403
errorCode : ForbiddenException

When the user is currently playing the game, the access token is deleted immediately after the device block is registered in the console, and the 'bad accessToken' error shown below is printed on all methods.

  • When the user's Access Token is wrong or expired
    statusCode : 401
    errorCode : BadUnauthorizedException

  • When the user's Access Token is wrong or expired upon logging in
    statusCode : 401
    errorCode : BadUnauthorizedException

Therefore, the user must reissue the token or issue an access token through re-login to call methods properly.
However, as shown in the description above, the user cannot log in because a 403 error occurs when attempting to log in from a blocked device.

This means that you can also immediately disable a user's gameplay by blocking the device while that user is in the middle of playing the game.

As such, the developer needs to form a logic that confirms that the device block error occurred in the token reissuing method that proceeds once 'badaccessToken' occurs.

Logic configuration

When handling a device as an exception from the blocked devices, it is recommended to check the error from only the login method instead of checking device block error cases for all BACKND methods.

If a device is blocked during use, a 'bad accesstoken error' occurs. Please note that because calling Backend.BMember.RefreshTheBackendToken() and reissuing the token are also regarded as login behavior, BACKND advises you to check the error upon reissuing the token.

BackendReturnObject bro = Backend.GameData.Get("tableName", new Where());
if(bro.IsSuccess() == false) {
if(bro.IsBadAccessTokenError()) {
var bro2 = Backend.BMember.RefreshTheBackendToken();

if(bro2.IsSuccess() == false && bro2.IsDeviceBlockError()) {
Debug.Log("The device has been blocked.");
}
}
}

The method that checks whether the occurred error is the device block error is as follows:

You can also implement the device block with a single configuration of the handler without using the logic above if you put a check on BACKND Inspector's(TheBackend menu on the upper section of Unity > Edit Settings) Auto Refresh Token.

void Start() {
Backend.ErrorHandler.OnDeviceBlockError= () => {
Debug.Log("Device block occurred!");
};
}

void GetData(){
BackendReturnObject bro = Backend.GameData.Get("tableName", new Where());
}

The handler operates according to the following steps:

  1. Checks the occurrence of '401 bad accesstoken' whenever a BACKND method is called
  2. When '401 bad accesstoken' occurs, calls the token reissuing method
  3. Calls the handler if the 403 device block error was found in the return case of the reissuing method