Skip to main content

Put it all together - Login with single platform auth - (Unreal Engine module)

Last updated on May 27, 2025

Connect the UI to let player log in with single platform auth​

In this tutorial, you will learn how to connect the SinglePlatformAuthWidget_Starter class with the AuthEssentialsSubsystem_Starter subsystem to handle the single platform auth login process.

  1. Open the SinglePlatformAuthWidget_Starter C++ class and ensure that your class has the following highlighted code in the NativeOnActivated() function.

    void USinglePlatformAuthWidget_Starter::NativeOnActivated()
    {
    // ...
    if (ShouldAutoLogin())
    {
    OnLoginWithSinglePlatformAuthButtonClicked();
    return;
    }

    const FString LoginButtonText = TEXT_LOGIN_WITH.ToString().Replace(TEXT("%PLATFORM%"), *GetDefaultNativePlatform());
    Btn_LoginWithSinglePlatformAuth->SetButtonText(FText::FromString(LoginButtonText));
    Btn_LoginWithSinglePlatformAuth->OnClicked().AddUObject(this, &ThisClass::OnLoginWithSinglePlatformAuthButtonClicked);
    LoginWidget->SetButtonLoginVisibility(ShouldDisplayDeviceIdLogin() ? ESlateVisibility::Visible : ESlateVisibility::Collapsed);
    }
  2. In the same class, add the following highlighted code to the OnLoginWithSinglePlatformAuthButtonClicked() function.

    void USinglePlatformAuthWidget_Starter::OnLoginWithSinglePlatformAuthButtonClicked()
    {
    // Set the login widget to logging in state and bind the retry login delegate.
    LoginWidget->SetLoginState(ELoginState::LoggingIn);
    LoginWidget->OnRetryLoginDelegate.AddUObject(this, &ThisClass::OnLoginWithSinglePlatformAuthButtonClicked);

    // Login with single platform auth is considered as login with default native platform.
    // Thus, it doesn't need username, token, nor the login method.
    AuthSubsystem->SetAuthCredentials(EAccelByteLoginType::None, TEXT(""), TEXT(""));
    AuthSubsystem->Login(GetOwningPlayer(), FAuthOnLoginCompleteDelegate::CreateUObject(LoginWidget, &std::remove_pointer_t<decltype(LoginWidget)>::OnLoginComplete));
    }

Resources​