Authentication with Steam
Steam authentication with App ID 480 is no longer supported by the EOS SDK. Make sure you have your own Steam App ID for the authentication to work.
Starting from version 4.0.0, the Steam login method is pretty smooth and easy to implement. Let's dive into the steps to set up the Steam login method in your Unreal Engine project.
Setting up Epic Developer Portal
- Go to the Epic Games Developer Portal (opens in a new tab) and select your project.
- Now under Product Settings, click on Identity Providers and press on Add Identity Provider.
-
Select Steam from the list and fill the required information:
- Description: This can be any Description you want to give to the Identity Provider.
- Encryption Key: This should be a empty string.
- SteamNetworkingIdentity value: This should be set to
epiconlineservices
if you are using Unreal Engine 5.4 or above. For Unreal Engine 5.3 or below, this should be a empty string. If you are using Steam Integration Kit (opens in a new tab), then this should always be set toepiconlineservices
. - OAuth Client ID: This should be a empty string.
- App ID: This should be your Steam App ID. If you don't have a Steam App ID, you can get it from the Steamworks (opens in a new tab) website.
- To attach the Identity Provider to your sandbox, go to Sandboxes and select the sandbox you want to attach the Identity Provider to. Now click on Identity Providers and select the profile you just created. Press Save and you are done!
This will take a few minutes to get it to populate, give it a few minutes and you are ready to go!
Project Setup
-
Enable the Steam Plugin that you want to use in your project. You can do this by going to Edit -> Plugins and search for Online Subsystem Steam or Steam Integration Kit and enable it.
-
If you are using the Steam Integration Kit, just configure the plugin with your Steam App ID and you are good to go. If you are using the Online Subsystem Steam, you need to add the following lines to your DefaultEngine.ini:
[OnlineSubsystem]
DefaultPlatformService=EIK
NativePlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=[Your Steam ID]
Code Implementation
Blueprint Implementation
Onto the final step! Now that you have set up the Steam login method in the Epic Developer Portal and your Unreal Engine project, you can start implementing the Steam login method in your project. Here are some examples of how you can do this.
Using Connect interface
Cannot view the code? Click here (opens in a new tab)
Using Auth interface
If the user is logging in for the first time with steam, and no epic account is attached, then the user will be prompted to link their account to an Epic Account. This will be a one time process and the user will not be prompted again.
That is it! You have successfully implemented the Steam login method in your Unreal Engine project. Now you can authenticate your users using their Steam account.
C++ Implementation
Build.cs File
Add the following lines to your Build.cs
file:
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemUtils", "OnlineSubsystemEIK" });
Header File
#include "OnlineSubsystem.h"
#include "OnlineSubsystemUtils.h"
#include "Interfaces/OnlineIdentityInterface.h"
/**
*
*/
public:
// This function is used to login using the Steam
void LoginWithSteam();
void LoginWithSteamCallback(int32 LocalUserNum, bool bWasSuccess, const FUniqueNetId& UserId, const FString& Error);
Source File
void UMyGameInstanceSubsystem::LoginWithSteam()
{
if(IOnlineSubsystem* SteamOnlineSub = Online::GetSubsystem(GetWorld(), STEAM_SUBSYSTEM))
{
if(IOnlineIdentityPtr SteamIdentityInterface = SteamOnlineSub->GetIdentityInterface())
{
IOnlineIdentity::FOnGetLinkedAccountAuthTokenCompleteDelegate Delegate = IOnlineIdentity::FOnGetLinkedAccountAuthTokenCompleteDelegate::CreateLambda([this](int32 LocalUserNum, bool bWasSuccess, const FExternalAuthToken& AuthToken)
{
if(bWasSuccess)
{
if(IOnlineSubsystem* EIKOnlineSub = Online::GetSubsystem(GetWorld(), "EIK"))
{
if(IOnlineIdentityPtr EIKIdentityInterface = EIKOnlineSub->GetIdentityInterface())
{
FOnlineAccountCredentials AccountDetails;
// If you want to use EAS, you can use the following type
AccountDetails.Type = "eas_+_EIK_LCT_ExternalAuth_+_EIK_ECT_STEAM_SESSION_TICKET";
// If you want to do the login without EAS, you can use the following type
// AccountDetails.Type = "noeas_+_EIK_ECT_STEAM_SESSION_TICKET";
AccountDetails.Token = AuthToken.TokenString;
EIKIdentityInterface->OnLoginCompleteDelegates->AddUObject(this, &UMyGameInstanceSubsystem::LoginWithSteamCallback);
EIKIdentityInterface->Login(0, AccountDetails);
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("LoginWithSteam: EIK OnlineSubsystem not found."));
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("LoginWithSteam: Login was not successful."));
}
});
SteamIdentityInterface->GetLinkedAccountAuthToken(0, "Session", Delegate);
}
}
}
void UMyGameInstanceSubsystem::LoginWithSteamCallback(int32 LocalUserNum, bool bWasSuccess, const FUniqueNetId& UserId,
const FString& Error)
{
if(bWasSuccess)
{
UE_LOG(LogTemp, Warning, TEXT("LoginWithSteamCallback: Login was successful. UserID: %s"), *UserId.ToString());
}
else
{
UE_LOG(LogTemp, Error, TEXT("LoginWithSteamCallback: Login was not successful. Error: %s"), *Error);
}
}