Authentication with Steam #
In this section, we’ll log into the platform with Steam. This method is appropriate for use in production.
Prerequisites:
- A Steam account associated with a Steamworks organization
- Set Up the Unreal SDK
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.
- Log into Steamworks.
- Hover over Users & Permissions, then click Manage Groups.
- Select a group or create a new group.
- Create or view your Steamworks Web API Key.
- 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 Engine Steam Identity Provider #
Navigate to the
pragma-engine/platform/PROJECT/config/directory and openlocal-dev.yml.Insert the following code while making sure to edit in your Application ID and Web API Key:
Be sure to nest the configuration under AccountService.identityProviderPlugins if you already have other identity providers configured.social:
shared:
configs:
Steam: # credentials are configured here to be used by any service or plugin that needs to make calls to this provider
class: "pragma.shared.SteamCredentialsConfig"
config:
appId: "${steamAppId}"
steamWebAPIKey: "${steamWebApiKey}"
pluginConfigs:
AccountService.identityProviderPlugins:
plugins:
Steam:
class: "pragma.account.SteamIdentityProviderPlugin"
config:
sharedConfigKey: "Steam" # must match key under shared - can be customized
restrictByAppOwnership: false
restrictByAccountBan: false
playerLoginEnabled: true
operatorLoginEnabled: false
accountLinkingEnabled: true
accountUnlinkingEnabled: false
accountLinkingCooldownInDays: 0
accountLinkingOneAssociationOnly: false
showPortalLoginButton: false
visibleToOtherPlayers: true
steamWebAPIKey does not need to be encrypted when running Pragma Engine locally.- Run Pragma Engine via one of the following methods.
Once the engine has started successfully, it prints the message INFO main - Pragma server startup complete.
Enable Unreal’s Steam plugin #
You will need to replaceyour_app_idwith your app’s Steam App ID, andyour_service_identitywith an identifier of your choosing for the service that validates the ticket (see the note below).
- Open
DefaultEngine.inilocated in theUnreal Projects/[Project name]/Configdirectory 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
DefaultRemoteServiceIdentity=your_service_identity
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
[PacketHandlerComponents]
+Components=OnlineSubsystemSteam.SteamAuthComponentModuleInterface
DefaultRemoteServiceIdentityis required when acquiring a ticket with the"WebAPI"token type (used byGetLinkedAccountAuthTokenin the login code below). Unreal’s Steam Online Subsystem reads this value and passes it to Steam’sGetAuthTicketForWebApi, which bakes it into the ticket as the identity of the service that will validate it; if it is left unset, ticket acquisition fails withLogOnlineIdentity: Warning: STEAM: FOnlineIdentitySteam::GetLinkedAccountAuthToken DefaultRemoteServiceIdentity not set. The value is an arbitrary string you choose (for example, your game or backend name) - Pragma Engine validates the ticket without requiring a matching identity, so any non-empty value works.Alternatively, you can skip this config setting and supply the identity inline in the token type, appended after a colon - for example
GetLinkedAccountAuthToken(0, TEXT("WebAPI:your_service_identity"), ...). When the token type contains a colon, the part after it is used as the identity andDefaultRemoteServiceIdentityis ignored; the config value is only consulted when the token type has no inline identity (plain"WebAPI"). Use whichever you prefer - the config keeps the identity out of code, while the inline form keeps it next to the call site.
- Open
[Project Name].Build.cslocated in theUnreal Projects/[Project name]/Source/[Project name]directory and add"OnlineSubsystem", "OnlineSubsystemSteam", "Steamworks"toPublicDependencyModuleNames.AddRange. Confirm that yourPublicDependencyModuleNames.AddRangefollows this structure:
PublicDependencyModuleNames.AddRange(
new string[] {
"Core",
"CoreUObject",
"Engine",
"InputCore",
"PragmaSDK",
"PragmaSDKAux",
"OnlineSubsystem",
"OnlineSubsystemSteam",
"Steamworks"
}
);
- Open your project in Unreal Editor.
- Click on the Edit menu, then Plugins to open the Plugins window.
- Ensure that both the Online Subsystem and Online Subsystem Steam plugins are enabled, then restart Unreal Editor.
Integrate Steam login into your game #
We will use the MyPlayerController class we created in Log in from a Game Client to add a Steam login method.
Acquire the Steam ticket with the asynchronousGetLinkedAccountAuthTokenmethod (using the"WebAPI"token type) rather than the synchronousGetAuthToken. The synchronous method returns a ticket immediately - before Steam has finished propagating it to its authentication servers - which can cause the first login attempt to fail with a transient validation error. The asynchronous method waits for Steam’s confirmation callback before handing back the ticket, so the ticket is safe to use as soon as you receive it.
- In
MyPlayerController.h, declare the following method under thepublicaccess modifier:
UFUNCTION(Exec)
void LogInSteam();
- In
MyPlayerController.cpp, add the following include statements:
#include "OnlineSubsystem.h"
#include "Interfaces/OnlineIdentityInterface.h"
- In
MyPlayerController.cpp, define theLogInSteam()method.Player->LogIntakes aFGetProviderTokenDelegateinstead of a raw token: a token fetched too early can expire while the player waits in the login queue, so the delegate defers the actual Steam ticket request until the SDK is ready to use it, once the player has cleared the queue. The delegate must callOnResultexactly once: with the token on success, or with a failure if the ticket can’t be obtained, which ends the login immediately with that error:
void AMyPlayerController::LogInSteam()
{
const Pragma::FPlayer::FGetProviderTokenDelegate GetProviderToken =
Pragma::FPlayer::FGetProviderTokenDelegate::CreateWeakLambda(
this, [this](Pragma::FPlayer::FProviderTokenReadyDelegate OnResult)
{
IOnlineSubsystem* OSS = IOnlineSubsystem::Get(TEXT("STEAM"));
if (OSS == nullptr)
{
OnResult.ExecuteIfBound(Pragma::FPragmaProviderTokenResult::Failure(TEXT("Steam Online Subsystem is unavailable.")));
return;
}
OSS->GetIdentityInterface()->GetLinkedAccountAuthToken(0, TEXT("WebAPI"),
IOnlineIdentity::FOnGetLinkedAccountAuthTokenCompleteDelegate::CreateWeakLambda(
this, [OnResult](int32 LocalUserNum, bool bWasSuccessful, const FExternalAuthToken& AuthToken)
{
if (!bWasSuccessful || !AuthToken.HasTokenString())
{
OnResult.ExecuteIfBound(Pragma::FPragmaProviderTokenResult::Failure(TEXT("Failed to acquire a Steam auth ticket.")));
return;
}
OnResult.ExecuteIfBound(Pragma::FPragmaProviderTokenResult::Success(AuthToken.TokenString));
}));
});
Player->LogIn(
EPragma_Account_IdProvider::STEAM,
GetProviderToken,
Pragma::FPlayer::FLoggedInDelegate::CreateWeakLambda(
this, [this](const TPragmaResult<>& Result)
{
if (Result.IsSuccessful())
{
UE_LOG(LogTemp, Display, TEXT("Pragma -- Logged in with Steam."));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Pragma -- Steam login failed: %s"),
*Result.GetErrorAsString());
}
}));
}
- Compile the project in your IDE.
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.
In the Edit menu under Project Settings…, ensure that your project’s Default GameMode is set to MyGameModeBase before packaging a standalone version of your project.- 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.
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.
Navigate to the location of the built project. You should find
[Your project name].exeinside theWindowsNoEditordirectory.Create a shortcut to
[Your project name].exe, then right-click the shortcut left-click Properties.In the Shortcut Properties window, add a space and
-logto the end of the Target field. The Target field should readpath to your executable\[Your project name].exe -log. You will now see a separate log window appear when launching your standalone game via this shortcut.Open your standalone game using the shortcut you just created.
Run the game, open the in-game console with
~, and typeLogInSteam.If successful, you should see the app you registered with Steam running inside the Steam client. A separate log window should open and you should see a successful login attempt via Steam.
For extra confirmation, you can use the Pragma Portal to verify a successful Steam login.
Navigate to http://localhost:11200/ to load Pragma Portal. Select Sign in with Pragma Unsafe and type in test04.
Confirm you see a player with your Steam display name listed in the Accounts section of the portal. Clicking on this player should show that the identity provider for this player is Steam.





