Set up Steam as an identity provider
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.
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 Shared CloudIn the Shared Cloud 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.
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
In the AGS Admin portal, go to your publisher namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Auth & Account Linking page, click on the + Add New button.
From the list of login method options, select Steam Web.
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.
noteIf you enter an invalid Steam Publisher Web API Key, you will see "Steam Web API Key is invalid" error message
Next to Integration, click Activate. On the pop-up that appears, click Activate to confirm.
Give it a try
Go to the Player Portal and click the Login button.
If you can't find the Steam icon, you can click More login options.
Click Login with Steam.
You will be redirected to the Steam Web Login page where you can fill in your Steam credentials.
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
In the AGS Admin portal, go to your game namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Auth & Account Linking page, click on the + Add New button.
Click on Steam SDK.
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.
noteIf you enter an invalid Steam Publisher Web API Key, you will see "Steam Web API Key is invalid" error message
Next to Integration, click Activate. On the pop-up that appears, click Activate to confirm.
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.
- Unreal Engine Instructions
- Unity Instructions
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
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"
AppId
is your Steam Game App ID.
Recommended DefaultEngine.ini settings (Unreal)
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);
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.
In-game login integration (Unity)
You can integrate your Steam game to sign in with the AGS SDK so that your players can log in to games using their Steam credentials.
Preparation and configuration (Unity)
Project settings (Unity)
For more information about opening the SDK Config, see Install and configure the SDK. Then, fill in each attribute based on the AGS Admin Portal values and save the configuration.
Sample code implementation (Unity)
In this sample code implementation, we will use Steamworks.NET as the wrapper of Steam SDK.
This example requires Steamworks.Net with a minimum version 20.2.0.
Generate Steam token
You can generate a Steam ticket with a new API called GetAuthTicketForWebApi
.
using AccelByte.Core;
using AccelByte.Models;
using Steamworks;
/// <summary>
/// API to generate Steam token
/// </summary>
/// <param name="serviceId">Value of any unique identifier</param>
public static void GenerateSteamTicket(string serviceId, System.Action<string> onGetSteamTokenFinished)
{
if (!SteamManager.Initialized)
{
Debug.LogError("Failed to initialize Steam");
return;
}
Callback<GetTicketForWebApiResponse_t> getAuthSessionTicketResponse = null;
GetTicketForWebApiResponse_t? responseResult = null;
getAuthSessionTicketResponse = Callback<GetTicketForWebApiResponse_t>.Create(response =>
{
getAuthSessionTicketResponse.Dispose();
responseResult = response;
if (response.m_eResult == EResult.k_EResultOK)
{
byte[] bytes = response.m_rgubTicket;
int byteSize = response.m_cubTicket;
string steamTicket = System.BitConverter.ToString(bytes, startIndex: 0, byteSize);
steamTicket = steamTicket.Replace("-", string.Empty);
Debug.Log($"Get steam ticket:\n{steamTicket}");
onGetSteamTokenFinished?.Invoke(steamTicket);
}
else
{
Debug.LogError("Failed to get Steam token");
onGetSteamTokenFinished?.Invoke(null);
}
});
SteamUser.GetAuthTicketForWebApi(serviceId);
}
platform_token
for Epic Games Authentication is Access Token or Auth Code.
Log in to the AccelByte IAM Service.
private void LoginAccelByteSteamPlatform(string serviceId)
{
GenerateSteamTicket(serviceId, steamTicket =>
{
if (string.IsNullOrEmpty(steamTicket))
{
Debug.LogError("Steam ticket is empty");
return;
}
AccelByte.Api.User user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
string platformToken = $"{serviceId}:{steamTicket}";
user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.Steam, platformToken, OnLoginWithSteamDone);
});
}
private void OnLoginWithSteamDone(Result<TokenData, OAuthError> loginResult)
{
if (loginResult.IsError)
{
Debug.Log($"Login failed, Error: {loginResult.Error.error}, Description {loginResult.Error.error_description}");
}
else
{
Debug.Log("Login 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.