Skip to main content

Implement login with device ID

Last updated on January 24, 2024

Overview

The simplest authentication method for AccelByte Gaming Services (AGS) is login via a Device ID, which is a unique string for device identification. Device ID can refer to a computer's serial number, the International Mobile Equipment Identity (IMEI) of a mobile device, or another unique identifier. You can use Device ID for testing and as an easy way for players to log in to mobile games without an account.

When players use Device ID, they can log in to your game without entering any registration or credentials. When a player logs in for the first time, the system creates an account automatically, allowing access to different services such as Matchmaking, Friend management, or Store.

Warning

Use login with Device ID for development only. This authentication method is made to test integration with our services.

Tutorial

Follow this tutorial to implement Login via Device ID in your game.

Configure a login method in the Admin Portal

AGS supports many login methods; choose which login methods you want to activate.

  1. To activate the Device ID login method, open your Admin Portal dashboard and select your game namespace. From the side menu pane of the dashboard, select Login Methods > Add New.

    Add new login method

  2. The system directs you to a new menu that displays all of AGS's login methods. Select Device to add the Device ID login method.

    Add Device ID login method

  3. Next, the system displays a pop-up window where you configure the login method. You only need to fill in the Redirect URI, which redirects the player once account authorization succeeds. The default URI is http://127.0.0.1. Once done, click Create.

    Create login method

  4. A new menu appears that displays your configuration settings and status, which should be Active. If the menu doesn't appear, click Activate to select the Device ID login method.

    Configuration settings

You have now configured and activated the Device ID login method in the Admin Portal. Next, implement Login with Device ID in your game project.

Implement Login into your game

Implement Login with Device ID in your game with this sample code.

IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get(ACCELBYTE_SUBSYSTEM);
ensure(Subsystem != nullptr);

FOnlineIdentityAccelBytePtr IdentityInterface = nullptr;
ensure(FOnlineIdentityAccelByte::GetFromSubsystem(Subsystem, IdentityInterface));

int32 LocalUserNum = 0;
FOnlineAccountCredentialsAccelByte Credentials{ EAccelByteLoginType::DeviceId, TEXT(“”), TEXT(“”) };
// Login
IdentityInterface->AddOnLoginCompleteDelegate_Handle(LocalUserNum
, FOnLoginCompleteDelegate::CreateLambda([](int32 LocalUserNum, bool bLoginWasSuccessful, const FUniqueNetId& UserId, const FString& LoginError)
{
if (bLoginWasSuccessful)
{
// Do something when player successfully logged in
}
else
{
// Do something when player failed to log in
}
})
);
IdentityInterface->Login(LocalUserNum, Credentials);

Congratulations! You logged into our platform and can unlock the full potential of AGS.