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.

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:

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
    void Start()
        // To make sure Steamworks.NET is initialized
       if (!SteamManager.Initialized)
        var ticket = new byte[1024];
        var networkIdentity = new SteamNetworkingIdentity();
        var newTicket = SteamUser.GetAuthSessionTicket(ticket, 1024, out uint ticketSize, ref networkIdentity);
        CSteamID SteamID = SteamUser.GetSteamID();

        LootLockerSDKManager.VerifyPlayerAndStartSteamSession(SteamID.ToString(), ref ticket, ticketSize, (response) =>
            if (!response.success)
                Debug.Log("Error starting a LootLocker session from the Steam User: " + response.errorData.ToString());
            Debug.Log("Successfully started a LootLocker session from Steam User with ID: " + SteamID.ToString());

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