Links

Steam

Authenticate your players using their active Steam session and register a session for them on the LootLocker backend.
To use Steam in your game you must be a registered developer and have a game with SteamWorks

Configure Steam in LootLocker

Go to Platform Settings in the LootLocker Web Console and make sure the Steam platform is enabled.
LootLocker Steam Settings

Steam App ID

To get the Steam App ID you have to log in to the SteamWorks Partner Dashboard.
The App ID is behind the red square

Steam Publisher Key

To find the Steam Publisher Key you can follow this guide from Valve.

Install SteamWorks in Your Project

Before we can authenticate with Steam and start a LootLocker session we must have access to a few features from the SteamWorks API.
To learn more about authentication with Steam you can read their documentation for Session Tickets in SteamWorks.
Unity
Unreal
Remember to set Steam as platform in the LootLocker SDK Settings in your Unity project.
Our recommended way to gain access to the SteamWorks API in a Unity Game is by using the 3rd party library called Steamworks.NET
Install Steamworks.NET using the instructions found here: http://steamworks.github.io/installation/
To learn now to configure your game to work with Steam, please follow the directions found here:

Authenticate Player

After installing SteamWorks in your project
Unity
Unreal
We'll start by creating a new empty Game Object in your scene and calling it GameManager. Feel free to skip this if you already have a GameManager or similar in your game.
Creating empty GameObject
In this new GameObject you can add a new script called GameManager.
Create new sccript on GameObject
Open up your new script in your editor of choice and add the following code:
using LootLocker.Requests;
using Steamworks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
void Start()
{
// To make sure Steamworks.NET is initialized
if (!SteamManager.Initialized)
{
return;
}
var ticket = new byte[1024];
SteamUser.GetAuthSessionTicket(ticket, 1024, out uint ticketSize);
Array.Resize(ref ticket, (int)ticketSize);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ticketSize; i++)
{
sb.AppendFormat("{0:x2}", ticket[i]);
}
var steamSessionTicket = sb.ToString();
LootLockerSDKManager.VerifySteamID(steamSessionTicket, (response) =>
{
if (!response.success)
{
Debug.Log("error verifying steam ID");
return;
}
Debug.Log("successfully verified steam user");
});
}
}
You do not need to store the result of this call anywhere as LootLocker knows to expect a Game Session call within 5 minutes.
Retrieve the Steam Session Ticket
The following steps will help you to retrieve the SteamSessionTicket from the Online Subsystem from the previous step.
Create a new Class called GetSteamSessionTicketHelper and paste the following code after the last include in the .h file:
class IOnlineSubsystem;
Paste the following code as well in the .h file:
public:
UFUNCTION(BlueprintCallable, CallInEditor, Category = "LootLocker | GetSteamSessionTicket")
static FString GetSteamSessionTicket();
Paste the following code in the .cpp file:
FString GetSteamSessionTicketHelper::GetSteamSessionTicket()
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
FString IdentityToken = OnlineSub->GetIdentityInterface()->GetAuthToken(0);
return IdentityToken;
}
Return to the editor and compile.
The final step is to retrieve the token, which can be done in Blueprint or in C++.
Verify the Player
In Blueprint you can retrieve the token by finding the node you just made above: GetSteamSessionTicket in the LootLocker | GetSteamSessionTicket category. This is static so you can find it by right-clicking anywhere within the Event Graph.
Then you can pass the SteamSessionTicket(the result of that node) to the Verify Player node which you can find by right-clicking anywhere within the Event Graph.
To copy and paste the above example into your editor, look here. Remember however that you need the GetSteamSessionTicket that you made above for this to work.

Input

You need to exchange the TriggerSteamAuthentication event for whatever event you want to use to trigger the login flow.
Remove the node GetSteamSessionTicket for your own one that you made above.

Output

We recommend branching the completed events on the success flag, and if you do this you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.
You can not test authentication with Steam in the editor. You need to package your game before it can connect to Steam.

Register a Session

Now that we have successfully verified the Session Ticket with LootLocker, we are ready to register a Game Session. This call will return a lot of data that you can use to display to the Player or make more calls to LootLocker during this session.
You have 5 minutes to register a Game Session after a successful Player Verification response before starting over with a new Player Verification.
Unity
Unreal
Add the following snippet to your GameManager after verifying the Steam user:
CSteamID SteamID = SteamUser.GetSteamID();
LootLockerSDKManager.StartSteamSession(SteamID.ToString(), (response) =>
{
if (!response.success)
{
Debug.Log("error starting sessions");
return;
}
Debug.Log("session started!");
});
For a combined snippet including verification and session start see this gist.
To copy and paste the above example into your editor, look here.

Input

You need to exchange the TriggerSteamStartSession event for whatever event you want to use to trigger the login flow. It is highly likely that you want the input event for this to be the output event from the successful execution of player authentication.
Remove the node REPLACE: Steam Id so that you provide the actual steam id.

Output

We recommend branching the completed events on the success flag, and if you do this you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.
Congratulations - you have now started using LootLocker in your game with Steam! Next up we suggest you look at our feature set, and decide which ones you want to use in your game.