Information in this guide is correct from date of upload: 2024/10/21
A step by step authentication tutorial made to facilitate getting started with Steam and Unity Authentication.
Requirements
- SteamWorks Developer account with at least 1 application**
- Steam **
- SteamWorks Wrapper SDK
- Latest version of the Unity Authentication SDK with package manager
- Unity Editor version 2021.1 and above
** We assume that you have a Steam account or Steam Developer account. If not please follow the existing steam guide
Steam Configuration
This section will go over the general setup within SteamWorks.
SteamWorks
The following information assists in retrieving and setting up the Publisher Web API Key and the App ID.
-
Log in to the SteamWorks dashboard with a user who has administrative rights.
-
On the Main SteamWorks page select Users & Permissions > Manage Groups.
-
Select the Group to be modified; by default, Everyone should be visible.
-
Create a WebAPI key on the right hand side of the page under edit group:
-
Copy the Web API key, as it will be necessary when setting up the Unity project.
-
Copy the App ID:
-
Go to SteamWorks dashboard > Apps & Packages > All Applications.
-
Select the newly created application.
-
The App ID can be found in the URL and in brackets next to the app name.
With all the necessary information gathered, the setup can continue within the Unity Editor.
Unity Configuration
This section will go over the general setup within the Unity Editor.
SDK Configuration
- Create or Open a new Unity Project.
- Download the latest version of the SteamWorks SDK.
- In Unity, go to Assets > Import Package > Custom Package and select the SteamWorks .unitypackage file to import.
- Install the Unity Authentication SDK with package manager.
- In Unity, go to Windows > Package Manager > Packages: (dropdown menu) > Unity Registry, and search Authentication in search bar.
- Once the installation is complete, a file named steam_appid.txt should appear in the root of the project.
- Update the application ID in the file with the previously obtained Steam App ID
- No spaces or special characters allowed.
SteamManager Object
- Right click in the Unity Editor hierarchy and select Create > Empty GameObject.
- Rename to SteamManager.
- Select the SteamManager game object and select Add Component.
- Search for SteamManager.cs from the list and add it to the newly created SteamManager game object.
SteamAuthentication Object
- Right click in the Unity editor hierarchy and select Create > Empty GameObject.
- Rename to SteamAuthentication.
- Select the SteamAuthentication game object and select Add Component.
- Scroll down and click New script.
- Name script SteamAuthentication.
- Copy the following script directly into the newly created SteamAuthentication script.
- Make sure to change identity (ugsIdentity) to something unique with lowercase characters:
using Unity.Services.Authentication;
using System.Threading.Tasks;
using UnityEngine;
using System;
using Steamworks;
using Unity.Services.Core;
public class SteamAuthentication : MonoBehaviour
{
//Variables
Callback<GetTicketForWebApiResponse_t> m_AuthTicketForWebApiResponseCallback;
HAuthTicket m_AuthTicket;
string m_SessionTicket;
//an identity that you create unique to the application
private const string ugsIdentity = "unity";
async void Start()
{
await UnityServices.InitializeAsync(); //Initialize UnityServices
SignInWithSteam();
}
public void SignInWithSteam()
{
m_AuthTicketForWebApiResponseCallback =
Callback<GetTicketForWebApiResponse_t>.Create(OnAuthCallback);
m_AuthTicket = SteamUser.GetAuthTicketForWebApi(ugsIdentity);
}
async void OnAuthCallback(GetTicketForWebApiResponse_t callback)
{
// Call Unity Authentication SDK to sign in or link with Steam.
// Retrieve the SteamID from SteamNetworkingIdentity.
m_SessionTicket =
BitConverter.ToString(callback.m_rgubTicket).Replace("-", string.Empty);
m_AuthTicketForWebApiResponseCallback.Dispose();
m_AuthTicketForWebApiResponseCallback = null;
Debug.Log($"Steam Login success. Session Token: {m_SessionTicket} | Identity {ugsIdentity}");
await SignInWithSteamAsync(m_SessionTicket, ugsIdentity);
}
async Task SignInWithSteamAsync(string ticket, string identity)
{
try
{
await AuthenticationService.Instance.SignInWithSteamAsync(ticket, identity);
var playerInfo =
await AuthenticationService.Instance.GetPlayerInfoAsync();
string steamUserID = playerInfo.GetSteamId(); //Steam ID
string steamName = SteamFriends.GetPersonaName(); //SteamName
Debug.Log($"SteamID:{steamUserID} - Steam Name: {steamName}");
//Unity PlayerName
string playerName =
await AuthenticationService.Instance.GetPlayerNameAsync();
Debug.Log($"SignIn is successful: {playerName}");
}
catch (AuthenticationException ex)
{
// Compare error code to AuthenticationErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
catch (RequestFailedException ex)
{
// Compare error code to CommonErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
}
}
}
Unity Authentication Configuration
Almost at the finish line! A few more configuration steps and the application can be tested.
- Head to Edit > Project Settings > Services > Authentication.
- From the drop down list add Steam as an identity provider.
- Enter the Steam App ID that was copied earlier
- Enter the Steam Web API Key that was copied earlier
Testing
Following the above steps allows testing directly in the editor. Ensure that Steam is open; otherwise, an initialization failure error will occur.
The console should be logging the following if all is working as expected:
Common Errors
Initialisation failed If your initialization of SteamWorks fails, this indicates one of the following conditions:
- The Steam client isn’t running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
- The Steam client couldn’t determine the App ID of the application. If you’re running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
- Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
- Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
- Your App ID is not completely set up, i.e. in Release State: Unavailable, or it’s missing default packages.
Invalid Parameters The identity may be too long; keep it between 5 and 8 characters. Make sure the identity is in lowercase
Editor works, Build does not Ensure the steam_appid.txt is placed in the root of the build folder.
Permission Denied A Web API specific to the application may not have been created yet. Follow the steps above under SteamWorks WebAPI to set it up.
Friends not seeing me using/playing my app The application must be published and live for it to be visible to other Steam users.
Conclusion
This covers the basics of Steam and Unity sign-in. For further details, refer to the Unity Authentication documentation or visit Unity Discussions for assistance.

