Authenticating with Steam #

In this section, we’ll log into the platform with Steam. This method is appropriate for use in production. A Steam account associated with a Steamworks organization is required to complete this section.

Complete Setting Up the Unreal SDK and Logging Into the Platform before starting this section.

Acquire the Steam Application ID and Steamworks Web API key #

This guide assumes that you have already created and published your game on Steam. Consult Valve’s official Steam documentation for further assistance.
  1. Log into Steamworks.
  2. Hover over Users & Permissions, then click Manage Groups.

  1. Select a group or create a new group.

  1. Create or view your Steamworks Web API Key.
Create a key.

If a key doesn’t yet exist, you must create one by clicking Create WebAPI Key. It will then appear.

View an existing key.

If you selected an existing group which already has a Web API key, you’ll see it listed under the Web API box on the right-hand side.

  1. Take note of your game’s Steam Application ID. Hover over Users & Permissions, then click View Applications. The number that appears in the App Name column beneath the game name is the Steam Application ID.

Configure the Pragma Platform Steam Identity Provider #

  1. Navigate to the pragma-engine/platform/5-ext/config directory and open LocalConfig.yml.

  2. Insert the following code while making sure to edit in your Application ID and Web API Key:

Be sure to nest AccountService.steamIdentityProvider under pluginConfigs if you already have other identity providers configured.
social:
  pluginConfigs:
    AccountService.steamIdentityProvider:
      class: "pragma.account.SteamIdentityProvider"
      config:
        appId: "YOUR STEAM APPLICATION ID HERE"
        steamWebAPIKey: "YOUR STEAM WEB API KEY HERE"
  1. Run make run to start Pragma Engine. Run this in a terminal with platform as the working directory.
  • Alternatively, Pragma Engine can be run from IntelliJ. From the IntelliJ toolbar in the upper right, ensure MainKt - LocalConfigured is selected, then click the play button.

  • Once the engine has successfully started it prints the message [main] INFO main - Pragma server startup complete.

Enable Unreal’s Steam plugin #

You will need to replace your_app_id with your app’s Steam App ID.
  1. Open DefaultEngine.ini located in the Unreal Projects/[Project name]/Config directory and add the following configs:
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=your_app_id

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

[PacketHandlerComponents]
+Components=OnlineSubsystemSteam.SteamAuthComponentModuleInterface
  1. Open [Project Name].Build.cs and add "OnlineSubsystem", "OnlineSubsystemSteam", "Steamworks" to PublicDependencyModuleNames.AddRange. Confirm that your PublicDependencyModuleNames.AddRange follows this structure:
PublicDependencyModuleNames.AddRange(
    new string[] {
        "Core",
        "CoreUObject",
        "Engine",
        "InputCore",
        "PragmaSDK",
        "OnlineSubsystem",
        "OnlineSubsystemSteam",
        "Steamworks"
    }
);
  1. Open your project in Unreal Editor.
  2. Click on the Edit menu, then Plugins to open the Plugins window.
  3. Ensure that both the Online Subsystem and Online Subsystem Steam plugins are enabled, then restart Unreal Editor.

Integrate your game with Steam #

  1. After Unreal Editor reopens, open [Project name]GameModeBase.cpp.
  2. Add the following imports:
#include "Online.h"
#include "OnlineSubsystem.h"
  1. Add the following methods:
void A[Project name]GameModeBase::GetSteamToken()
{
  FString SessionTicket;
  IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
  SessionTicket = OSS->GetIdentityInterface()->GetAuthToken(0);

  LogInSteam(SessionTicket);
}

void A[Project name]GameModeBase::LogInSteam(const FString& SessionTicket)
{
  UPragmaAccountService::FLoggedInDelegate OnLoggedIn;
  OnLoggedIn.AddUObject(this, &A[Project name]GameModeBase::HandleLoggedIn);
 
  Session->Account().LogIn(EPragma_Account_IdProvider::STEAM, SessionTicket, OnLoggedIn);
}
  1. Open [Project name]GameModeBase.h and insert the following under the private access modifier:
void GetSteamToken();
void LogInSteam(const FString& SessionTicket);
  1. Compile the project using the green hammer icon at the top of the Rider window.

Build a standalone binary #

The Steam Online Subsystem in Unreal Engine does not work in PIE (Play In Editor) mode. It will still work if you run using the “Standalone Game” option.
  1. Build a standalone version of your game by going to the File menu, Package Project, then building a Windows (64-bit) version of the game.

  1. Ensure Pragma is running. Confirm that your Steam client is open and logged in with the same account used to get the Steam App ID.

  2. Navigate to the location of the built project. You should find [Your project name].exe inside the WindowsNoEditor directory. Run [Your project name].exe.

  3. If successful, you should see the app you registered with Steam running inside the Steam client.

  4. Navigate to http://localhost:10200/ to load Pragma Portal. Select Sign in with Pragma Unsafe and type in test04.

  5. Confirm you see a player with your Steam display name listed in the Players section of the portal. Clicking on this player should show that the identity provider for this player is Steam.