Steam
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.

Steam App ID
To get the Steam App ID you have to log in to the SteamWorks Partner Dashboard.

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 values from the SteamWorks API.
To learn more about authentication with Steam you can read their documentation for Session Tickets in SteamWorks.
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:
To learn now to configure your game to work with Steam, please follow the directions from the official GodotSteam documentation.
Authenticate Player
After adding SteamWorks integration in your project you can go ahead and authenticate the player. If successful, 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.
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.

In this new GameObject you can add a new script called GameManager.

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
{
// Consider offsetting this from the start method to avoid startup race conditions
void Start()
{
// To make sure Steamworks.NET is initialized
if (!SteamManager.Initialized)
{
return;
}
var ticket = new byte[1024];
var networkIdentity = new SteamNetworkingIdentity();
HAuthTicket ticketResult = SteamUser.GetAuthSessionTicket(ticket, ticket.Length, out uint actualTicketSize, ref networkIdentity);
if (ticket.Equals(HAuthTicket.Invalid))
{
Debug.LogWarning("Ticket from Steam was invalid: " + ticket.ToString());
yield break;
}
LootLockerSDKManager.VerifyPlayerAndStartSteamSession(ref ticket, actualTicketSize, (response) =>
{
if (!response.success)
{
Debug.Log("Error starting a LootLocker session from the Steam User: " + response.errorData.ToString());
return;
}
Debug.Log("Successfully started a LootLocker session from Steam User with ID: " + SteamID.ToString());
});
}Retrieve the Steam Session Ticket
The following steps will help you to retrieve the SteamSessionTicket from the Online Subsystem that you set up in the previous step.
Create a new UClass called USteamSessionHelper like this (this is the .h file):
#pragma once
#include "CoreMinimal.h"
#include "SteamSessionHelper.generated.h"
UCLASS(Blueprintable)
class USteamSessionHelper : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, CallInEditor, Category = "<YourProjectName> | SteamSessionHelper")
static FString GetSteamSessionTicket(int LocalUserNumber);
};Paste the following code in the .cpp file:
// Copyright (c) 2021 LootLocker
#include "SteamSessionHelper.h"
#include "Interfaces/OnlineIdentityInterface.h"
#include "OnlineSubsystem.h"
FString USteamSessionHelper::GetSteamSessionTicket(int LocalUserNumber)
{
const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(STEAM_SUBSYSTEM);
if (OnlineSubsystem == nullptr || OnlineSubsystem->GetSubsystemName() != STEAM_SUBSYSTEM)
{
//Handle error: "Could not get Steam Online Subsystem"
return "";
}
const IOnlineIdentityPtr IdentityInterface = OnlineSubsystem->GetIdentityInterface();
if (IdentityInterface == nullptr || !IdentityInterface.IsValid())
{
//Handle error: "Could not get Steam Online Subsystem Identity Interface"
return "";
}
if(IdentityInterface->GetLoginStatus(LocalUserNumber) != ELoginStatus::LoggedIn)
{
//Handle error: "Player is not logged in"
return "";
}
return IdentityInterface->GetAuthToken(LocalUserNumber);
}Generate Visual Studio project files and build the project.
You can now use these new methods to get the Steam session ticket from either blueprints or code.
Verify the Player and Start a LootLocker session
In Blueprint you can retrieve the token by finding the node you just made above: GetSteamSessionTicket in the <YourProjectName> | SteamSessionHelper category. This is static so you can find it by right-clicking anywhere within the Event Graph.
Then you can pass the SteamSessionTicket to the Start Steam Session Using Ticket 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.
Input
You need to exchange the TriggerSteamAuthentication event for whatever event you want to use to trigger the login flow.
This example does not include the nodes you made above to get the steam id and session ticket. So make sure to utilize those if you made them. If you're getting the values another way, then that's fine. Simply plug the values into the Verify Player and Start Steam Session node.
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.
The session response on a successful call also contains a lot of interesting information that you likely want to save, such as player_id, public_uid, and player_ulid among others.
You can not test authentication with Steam in the editor. You need to package your game before it can connect to Steam.
Follow the guide from GodotSteam on how to initialize Steam. Once Steam is properly initialized, open up the script from which you want to trigger LootLocker Authentication in Godot and add the following code.
var auth_ticket = Steam.getAuthSessionTicket()
if !auth_ticket.has('buffer'):
printerr("Steam Auth Session Ticket retrieval failed")
# Handle error as fit in your code
var authTicketString : String = LL_Authentication.ParseSteamAuthTicket(auth_ticket['buffer'], auth_ticket['size'])
if authTicketString.is_empty():
printerr("Auth ticket could not be parsed")
# Handle error as fit in your code
var steamLoginResponse = await LL_Authentication.SteamSession.new(authTicketString).send()
if(!steamLoginResponse.success) :
printerr("Login failed with reason: " + steamLoginResponse.error_data.to_string(), true)
# Handle error as fit in your code
print("Successfully started Steam session with LootLocker")To confirm that everything is running without errors, you can start your game and check the console for the correct message in the log.
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.
Last updated
