Steam
The following steps will demonstrate how to authenticate a player with Steam and register a session for that player 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:
1
using LootLocker.Requests;
2
using Steamworks;
3
using System;
4
using System.Collections;
5
using System.Collections.Generic;
6
using System.Text;
7
using UnityEngine;
8
9
public class NewBehaviourScript : MonoBehaviour
10
{
11
void Start()
12
{
13
// To make sure Steamworks.NET is initialized
14
if (!SteamManager.Initialized)
15
{
16
return;
17
}
18
19
var ticket = new byte[1024];
20
SteamUser.GetAuthSessionTicket(ticket, 1024, out uint ticketSize);
21
22
Array.Resize(ref ticket, (int)ticketSize);
23
StringBuilder sb = new StringBuilder();
24
for (int i = 0; i < ticketSize; i++)
25
{
26
sb.AppendFormat("{0:x2}", ticket[i]);
27
}
28
29
var steamSessionTicket = sb.ToString();
30
LootLockerSDKManager.VerifySteamID(steamSessionTicket, (response) =>
31
{
32
if (!response.success)
33
{
34
Debug.Log("error verifying steam ID");
35
return;
36
}
37
38
Debug.Log("successfully verified steam user");
39
});
40
}
41
}
42
Copied!
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 need to retrieve the SteamSessionTicketfrom the Online Subsystem.
Create a new Class called GetSteamSessionTicketHelper and paste the following code after the last include in the .h file:
1
class IOnlineSubsystem;
Copied!
Paste the following code as well in the .h file:
1
public:
2
UFUNCTION(BlueprintCallable, CallInEditor, Category = "LootLocker | GetSteamSessionTicket")
3
static FString GetSteamSessionTicket();
Copied!
Paste the following code in the .cpp file:
1
FString GetSteamSessionTicketHelper::GetSteamSessionTicket()
2
{
3
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
4
FString IdentityToken = OnlineSub->GetIdentityInterface()->GetAuthToken(0);
5
return IdentityToken;
6
}
Copied!
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

C++
Blueprint
Remember to place this code in the same class created above GetSteamSessionTicketHelper
1
void GetSteamSessionTicketHelper::DemoVerifyPlayer()
2
{
3
ULootLockerSDKManager::VerifyPlayer(GetSteamSessionTicket(), FLootLockerDefaultAuthenticationResponse::CreateUObject(this, &ADemoAuthentication::OnVerifyPlayerCompleted));
4
}
Copied!
In Blueprint you can retrieve the token by finding the node 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.
Get Session Ticke t
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

Unity
Unreal
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 you need to start over with a new Player Verification.
Add the following snippet to your GameManager after verifying the Steam user:
1
CSteamID SteamID = SteamUser.GetSteamID();
2
LootLockerSDKManager.StartSession(SteamID.ToString(), (response) =>
3
{
4
if (!response.success)
5
{
6
Debug.Log("error starting sessions");
7
return;
8
}
9
10
Debug.Log("session started!");
11
});
Copied!
For a combined snippet including verification and session start see this gist.
Besides the success boolean used in the snippet above, we also return a host of other data, such as the player’s ID, if they are a new or returning user etc. If you would like to dive deeper into this response, you can find the code for the SDK on GitHub or read our page in Understand the Session Registration Response.
C++
Blueprint
1
void GetSteamSessionTicketHelper::DemoStartSession()
2
{
3
ULootLockerSDKManager::StartSession(SteamID, FLootLockerSessionResponse::CreateUObject(this, &ADemoAuthentication::OnStartSessionCompleted));
4
}
Copied!
Besides the success boolean used in the snippet above, we also return a host of other data, such as the player’s ID, if they are a new or returning user etc. If you would like to dive deeper into this SessionResponse, you can find the code for the SDK on GitHub or continue to the next page in this tutorial, Understand the Session Registration Response.
Congratulations - you have now started using LootLocker in your game! Next up we suggest you look at our feature set, and decide which ones you want to use in your game.
If you want to store your player’s inventory with LootLocker (this allows use of a lot more features, such as granting assets to players on level up, when completing a mission, etc) a great next step is to read up on the Asset Manager.
Last modified 13d ago