Skip to main content

Set up Steam as an identity provider

Last updated on April 23, 2024

Overview

This guide is intended to help verified Steam developers connect Steam player accounts to AccelByte Gaming Services (AGS). Depending on your game, you may need to set up additional features within Steam services which are not listed here. For full information about setting up Steam services, we recommend contacting your Steam representative and reviewing Steam documentation directly.

important

This guide is intended for public use and contains limited information due to confidentiality. We recommend you refer to the full confidential guide first. To request a copy of the confidential guide, contact your AccelByte Technical Producer.

Goals

  • Enable the Steam authentication method for your game with the AGS SDK.
  • Enable the Steam authentication method for your publisher website with the AGS Player Portal.

Prerequisites

For web login integration

  • A valid Steam developer account and the ability to log in to Steamworks.

  • An AGS Admin Portal account to set up authentication and manage permissions.

  • A publisher namespace for your Player Portal and Launcher.

  • A Player Portal.

    AGS Starter

    In the Starter tier, you will need to provide your own player portal website.

For in-game login integration

  • A valid Steam developer account and the ability to log in to Steamworks.
  • An Unreal Engine Steam OSS.
    • UE V4.27 and below: Unreal Engine OSS
    • UE V5.0: Unreal Engine OSS
  • A Steamworks.NET 20.2.0 version or above for Unity.
  • A Steamworks SDK from the Steamworks page for Unreal Engine or Unity.
  • A Unity or Unreal game project with the latest version of the AGS SDK imported.
  • An AGS Admin Portal account to set up authentication and manage permissions.
  • A game namespace.
  • Familiarity with AGS Identity and Access Management (IAM) Clients.
  • Familiarity with AGS Identity and Access Management (IAM) Clients.

Set up a Steam app

Create a Steam app

Create a Steam application under your Steamworks account. For more details about Steam applications, refer to Steam's documentation for applications. Create a Steam application under your Steamworks account. For more details about Steam applications, refer to Steam's documentation for applications.

Create a Steam Publisher Web API Key

Create a Publisher Web API Key under your Group using Steamworks account. For more details about Steam Publisher Web API Key, please refer to the Steam's documentation for an overview of Web API. Create a Publisher Web API Key under your Group using Steamworks account. For more details about Steam Publisher Web API Key, please refer to the Steam's documentation for an overview of Web API.

Set up the Steam login method

Web login

  1. Log in to your AGS Admin portal, go to your publisher namespace, and click Login Method below the User Management sidebar. Next, click the + Add New button on the right side.

    AGS Admin Portal Steam Web click to add new login

  2. Click on Steam Web.

    AGS Admin Portal click to add Steam web login

  3. Fill in the Steam Publisher Web API Key from the Steamworks Portal and fill in Redirect URI with your domain URL (e.g., https://prod.gamingservices.accelbyte.io) and then click the Create button to finish.

    note

    If you enter an invalid Steam Publisher Web API Key, you will see “Steam Web API Key is invalid” error message

    AGS Admin Portal fill in Steam web API key

  4. Next to Integration, click Activate. On the pop-up that appears, click Activate to confirm.

    AGS Admin Portal Steam web login activate

Give it a try

  1. Go to the Player Portal and click the Login button.

    AGS Player Portal Steam web login page test

  2. If you can't find the Steam icon, you can click More login options.

    AGS Player Portal Steam web more login options test

  3. Click Login with Steam.

    AGS Player Portal Steam Login button test

You will be redirected to the Steam Web Login page where you can fill in your Steam credentials.

Steam web login test

note

Currently, players will be asked to link their Steam accounts with an existing AGS account or link it with a new account. There is an effort underway at AccelByte to make this configurable so players can log in to the Player Portal directly with a headless account.

In-game login

  1. Log in to the AGS Admin Portal, choose your game namespace, click Login Method below the User Management sidebar, and click the + Add New button on the right side.

    AGS Admin Portal in-game click to add new login

  2. Click on Steam SDK.

    AGS Admin Portal click to add Steam SDK login

  3. Fill in the App ID and the Steam Publisher Web API Key from the Steamworks Portal. Fill in the Redirect URI with http://127.0.0.1, and then click the Create Button.

    note

    If you enter an invalid Steam Publisher Web API Key, you will see “Steam Web API Key is invalid” error message

    AGS Admin Portal fill in Steam SDK API key

  4. Next to Integration, click Activate. On the pop-up that appears, click Activate to confirm.

    AGS Admin Portal Steam SDK login activate

Create an IAM client for Steam

An IAM client is a representation of the game client that you want to release on your target platform. Learn more about IAM Clients in Manage access control for applications.

In-game login instructions

The setup for each game engine is different. Please choose your game engine from the available tabs.

In-game login integration (Unreal)

You can integrate the Steam login using the AGS SDK so that your players can log in to games using their Steam credentials.

Preparation and configuration (Unreal)

Adding dependency (Unreal)

First, you need to add these public dependency modules: OnlineSubsystem, OnlineSubsystemSteam, and Steamworks. These are all the dependencies needed for integrating your project to use the Steam online subsystem within Unreal Engine.

public ABThirdPartyLogin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "AccelByteUe4Sdk", "Slate", "SlateCore" });

PrivateDependencyModuleNames.AddRange(new string[] { "Json", "OnlineSubsystem", "OnlineSubsystemSteam", "Steamworks", "HTTP" });
}

Add OnlineSubsystemSteam inside the <YourProject>.Target.cs and <YourProjectEditor>.Target.cs files.

public ABThirdPartyLoginTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemSteam" } );
}


public ABThirdPartyLoginEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemSteam" } );
}

Project settings for Steam login (Unreal)

Inside your DefaultEngine.ini file you need to add several variables for Steam configuration. You need this configuration to make certain that Steam will initiate automatically when opening the project.

To tell Unreal Engine to use the Steam Online Subsystem, add the following settings:

[OnlineSubsystem]
DefaultPlatformService=Steam

Now that you've told Unreal Engine that you want your application to use the Steam Online Subsystem, you'll need to configure the OnlineSubsystemSteam module by adding the following settings:

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
note

SteamDevAppId is your Steam Game App ID.

Specify the Steam class to the Net Driver for the application's connections:

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

Project settings for AGS (Unreal)

Add your AGS credentials in DefaultEngine.ini:

[/Script/AccelByteUe4Sdk.AccelByteSettings]
ClientId=<Your Client_Id>
ClientSecret=<Your Client_Secret>
Namespace=<Your Namespace>
PublisherNamespace=<Your Publisher Namespace>
RedirectURI="http://127.0.0.1"
BaseUrl="https://prod.gamingservices.accelbyte.io"
AppId=480
IamServerUrl="https://prod.gamingservices.accelbyte.io/iam"
PlatformServerUrl="https://prod.gamingservices.accelbyte.io/platform"
note

AppId is your Steam Game App ID.

After following these instructions, your DefaultEngine.ini file should look like the following example:

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=<your steam game app id>

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

[/Script/AccelByteUe4Sdk.AccelByteSettings]
ClientId=<Your IAM_Client_Id>
ClientSecret=<Your IAM_Client_Secret>
Namespace=<Your Namespace>
PublisherNamespace=<Your Publisher Namespace>
RedirectURI="http://127.0.0.1"
BaseUrl="https://prod.gamingservices.accelbyte.io"
AppId=<your steam game app id>
IamServerUrl="https://prod.gamingservices.accelbyte.io/iam"
PlatformServerUrl="https://prod.gamingservices.accelbyte.io/platform"

Sample code implementation (Unreal)

Next, we will show you how to implement the Steam authentication method for your game with sample code.

The IOnlineSubsystem reads the DefaultPlatformService value defined in DefaultEngine.ini. The IdentityInterface manages interactions with these services related to user accounts, enabling user authentication and access token retrieval. Once the operation is successful, the LoginWithOtherPlatform function of the AGS SDK handles third-party platform login using the authentication token obtained from the Identity Interface.

UE_LOG(LogTemp, Warning, TEXT("%s"), TEXT("Begin Login"));
const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if (OnlineSubsystem == nullptr)
{
FString Message = TEXT("Cannot login with no online subsystem set!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
OnActionInfoUpdated.Broadcast(Message);//will get active OSS Platform Service
return;
}

const IOnlineIdentityPtr OnlineIdentity = OnlineSubsystem->GetIdentityInterface();
if (!OnlineIdentity.IsValid())
{
FString Message = TEXT("Could not retrieve identity interface from native subsystem.");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
APlayerController* MyPlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);;

const ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(MyPlayerController->Player);
if (LocalPlayer == nullptr)
{
FString Message = TEXT("Can only login with native platform for local players");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
const FVoidHandler OnLoginSuccessDelegate = FVoidHandler::CreateLambda([=]() {
FAccountUserData AccountUserData = FRegistry::Credentials.GetAccountUserData();

FString AccountUserDataString;
FJsonObjectConverter::UStructToJsonObjectString(AccountUserData, AccountUserDataString);

FString Message = FString::Printf(TEXT("Login to AB Service Success : %s"), *AccountUserDataString);//Failed Login to AB Service
});
const FCustomErrorHandler OnLoginErrorDelegate = FCustomErrorHandler::CreateLambda([=](int32 ErrorCode, const FString& ErrorMessage, const FJsonObject& ErrorObject) {
FString Message = FString::Printf(TEXT("Error Login to AB Service : %s"), *ErrorMessage);
});

const FOnLoginCompleteDelegate NativeLoginComplete = FOnLoginCompleteDelegate::CreateLambda([=]
(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) {
UE_LOG(LogTemp, Warning, TEXT("OnLoginComplete %s : %s"), bWasSuccessful ? TEXT("Success") : TEXT("Fail"), *Error);
FString Message = FString::Printf(TEXT("OnLoginComplete %s : %s"), bWasSuccessful ? TEXT("Success") : TEXT("Fail"), *Error);
OnActionInfoUpdated.Broadcast(Message);

if (bWasSuccessful)
{
const FString PlatformToken = OnlineIdentity->GetAuthToken(LocalPlayer->GetControllerId());
UE_LOG(LogTemp, Warning, TEXT("PlatformToken : %s"), *PlatformToken);
OnActionInfoUpdated.Broadcast(FString::Printf(TEXT("PlatformToken : %s"), *PlatformToken));//Will Obtained Auth Ticket from OnlineIdentity

FRegistry::User.LoginWithOtherPlatform(EAccelBytePlatformType::Steam, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
UE_LOG(LogTemp, Warning, TEXT("Request LoginWithOtherPlatform"));
OnActionInfoUpdated.Broadcast(TEXT("Request LoginWithOtherPlatform"));
}//this method will hitting the AccelByte endpoint and will return value after success
});
OnlineIdentity->AddOnLoginCompleteDelegate_Handle(LocalPlayer->GetControllerId(), NativeLoginComplete);
const bool bWaitForDelegate = OnlineIdentity->Login(LocalPlayer->GetControllerId(), Credentials);
if (!bWaitForDelegate)
{
FString Message = TEXT("The online subsystem couldn't login");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
}

FString Message = TEXT("Sending login request to native subsystem!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
note

platform_token for Steam Authentication is the Auth Ticket.

After adding this sample code to your project, compile, build, and run your project. That's it!

Sample code testing (Unreal)

The image below shows a successful login using Steam with the sample code.

Steam login with sample code login Unreal success

Troubleshooting

In this section, you can find common errors and issues that may occur when using the service, along with recommendations on how to resolve them.

Misconfiguration

Your game won't be able to access the Steam login service if the Steam App ID is incorrect or missing in the Unreal Engine configuration (located in DefaultEngine.ini).

  • Double check the DefaultEngine.ini file and ensure the Steam App ID is configured correctly.

Steam login is not working

A player fails to log in with Steam due to a missing access token on the Steam side.

  • Ensure that the Steam app is running in the background.