Skip to content

Steam

This how-to walks you through configuring Steam authentication in LootLocker and starting a Steam session from your game.

Prerequisites

  • Unity, Unreal, or Godot SDK installed and configured in your project (not required for REST).
  • A registered Steamworks developer account and a game set up in Steamworks.

Configure Steam in LootLocker

Go to Platform Settings in the LootLocker Web Console and enable the Steam platform.

LootLocker Steam Settings

Steam App ID: log in to the Steamworks Partner Dashboard to find your App ID.

The App ID is behind the red square

Steam Publisher Key: follow this guide from Valve to find your Publisher Key.

Install Steamworks in Your Project

Before you can authenticate with Steam and start a LootLocker session, you need access to a few values from the Steamworks API. To learn more about authentication with Steam, read Valve's documentation on Session Tickets in Steamworks.

Install Steamworks.NET, the recommended third-party library for accessing the Steamworks API in a Unity game, using the instructions at http://steamworks.github.io/installation/.

Authenticate Player

Once Steamworks is integrated in your project, authenticate the player. A successful call returns data you can use to display information to the player or make further calls to LootLocker during this session.

Create a new empty GameObject in your scene named GameManager (skip this if you already have one), then add a new script to it called GameManager.

Create new script 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 GameManager : 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());
return;
}
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());
});
}
}

Conclusion

You've started using LootLocker in your game with Steam. Next, review LootLocker's full feature set to decide which other features to implement.