Authentication and login with Steam #

In this section, we’ll log into the platform with Steam.

Prerequisites:

Configure the Steam Account Identity Provider #

This guide requires you have set up your game as a Steam application. Consult Valve’s official Steam documentation for further assistance.

Portal

  • Navigate to the ID Provider page: select the Accounts Tab → ID Provider in the side menu.
  • Select a provider and fill out the form.
    • Each provider requires unique configuration.
  • Click Confirm.
  • Click Deploy.

Enable Unreal’s Steam plugin #

Update DefaultEngine.ini #

DefaultEngine.ini

[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=<STEAM-APP-ID> ; REPLACE WITH YOUR STEAM APP ID

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

[PacketHandlerComponents]
+Components=OnlineSubsystemSteam.SteamAuthComponentModuleInterface

Update the Build.cs #

[Project Name].Build.cs

PublicDependencyModuleNames.AddRange(
    new string[] {
        // ...
        "OnlineSubsystem",
        "OnlineSubsystemSteam",
        "Steamworks"
    }
);

Ensure the plugins are enabled #

  • Open your project in Unreal Editor.
  • From the Edit menu, select Plugins.
  • Check that the Online Subsystem and Online Subsystem Steam plugins are enabled. Enable and restart as needed.

Example log in and logout code #

This guide is based on an example Unreal project using the Third Person Unreal C++ project template. The example project is named ‘Narwhal’, update references accordingly.

In NarwhalPlayerController.h

// ...
public: 
  UFUNCTION(Exec)
  void LogInSteam();
  FString GetSteamToken();

  UFUNCTION(Exec)
  void LogOut();
//..

NarwhalPlayerController.cpp

// ...
#include "Online.h"
#include "OnlineSubsystem.h"
// ...

void ANarwhalPlayerController::LogInSteam() {
Player->LogIn(EPragma_Account_IdProvider::STEAM, GetSteamToken(),
      Pragma::FPlayer::FLoggedInDelegate::CreateWeakLambda(
          this, [this](const TPragmaResult<> &Result) {
              if (Result.IsSuccessful()) {
              UE_LOG(LogTemp, Display,
                      TEXT("-- Logged in with Steam."));
              } else {
              UE_LOG(LogTemp, Error,
                      TEXT("-- Steam log in failed: %s"),
                      *Result.GetErrorAsString());
              }
          }));
}

FString ANarwhalPlayerController::GetSteamToken() {
  IOnlineSubsystem *OSS = IOnlineSubsystem::Get();
  return OSS->GetIdentityInterface()->GetAuthToken(0);
}

void ANarwhalPlayerController::LogOut() {
  Player->LogOut(Pragma::FPlayer::FLoggedOutDelegate::CreateWeakLambda(
  	this, [] { UE_LOG(LogTemp, Display, TEXT("Pragma -- Logged out.")); }));
}

Log in with Steam #

  1. Log in to the Steam App. When using the Steam Online Subsystem, it’s expected that the player is already logged into and running the Steam client for full functionality.
  2. Package your project.
    The Steam Online Subsystem in Unreal Engine does not work in PIE (Play In Editor) mode.
  3. Run the game, open the in-game console with ~, and run LogInSteam.
  4. Verify success or failure from the logs.

View player’s account and identity providers in the Portal

  1. Navigate to the Portal.
  2. Confirm you see a player with the Steam display name listed in the Accounts page. Clicking on this player will show all details about the account. Under the Identity Providers section, there will be an entry for Steam.

Recap #

Players are now connected to the backend. Next, check out our feature guides.