Steam Addon
Integrate Steam authentication with PlayKit SDK for Unity
Steam Addon
The PlayKit Steam Addon provides seamless Steam login integration for your Unity games using Facepunch.Steamworks.
Current version: v0.1.0. Requires PlayKit SDK 0.2.0+.
Requirements
- Unity 2020.3 or later
- PlayKit SDK (com.playkit.sdk) 0.2.0+
- UniTask (com.cysharp.unitask) 2.5.0+
- Steam client running on the target machine
Installation
Via Unity Package Manager (Git URL)
- Open Window > Package Manager
- Click + > Add package from git URL
- Enter:
https://github.com/playkit-ai/playkit-unity-steam.git
Via manifest.json
Add to your Packages/manifest.json:
{
"dependencies": {
"com.playkit.sdk.steam": "https://github.com/playkit-ai/playkit-unity-steam.git#v0.1.0"
}
}Setup
1. Configure PlayKit Settings
- Go to Tools > PlayKit SDK > Settings
- Enter your Game ID (from PlayKit dashboard)
- Make sure your game is configured as a Steam channel (
steam_release,steam_demo, orsteam_playtest)
2. Configure Steam App ID
In your scene, add the PlayKit_SteamAuthManager component:
// Or set it via code
var steamAuth = gameObject.AddComponent<PlayKit_SteamAuthManager>();
steamAuth.SetSteamAppId(YOUR_STEAM_APP_ID);3. Authenticate
using PlayKit_SDK.Steam;
using Cysharp.Threading.Tasks;
public class GameManager : MonoBehaviour
{
private PlayKit_SteamAuthManager _steamAuth;
async void Start()
{
_steamAuth = GetComponent<PlayKit_SteamAuthManager>();
_steamAuth.OnAuthSuccess += (result) => {
Debug.Log($"Logged in! User: {result.userId}, Steam: {result.steamId}");
};
_steamAuth.OnAuthError += (error) => {
Debug.LogError($"Auth failed: {error}");
};
bool success = await _steamAuth.AuthenticateAsync();
}
}API Reference
PlayKit_SteamAuthManager
Main authentication manager component.
Properties
| Property | Type | Description |
|---|---|---|
IsAuthenticated | bool | Whether the user is currently authenticated |
SteamId | ulong | The user's Steam ID (64-bit format) |
SteamAppId | uint | The Steam App ID being used |
LastAuthResult | SteamAuthResult | The last authentication result |
Methods
| Method | Returns | Description |
|---|---|---|
SetSteamAppId(uint appId) | void | Set the Steam App ID at runtime |
AuthenticateAsync() | UniTask<bool> | Initialize Steam and authenticate with PlayKit |
Logout() | void | Clear authentication state |
Events
| Event | Description |
|---|---|
OnAuthSuccess | Fired when authentication succeeds |
OnAuthError | Fired when authentication fails |
PlayKit_SteamService
Low-level Steamworks wrapper for advanced use cases.
Properties
| Property | Type | Description |
|---|---|---|
IsInitialized | bool | Whether Steam is initialized |
SteamId | ulong | Current user's Steam ID |
SteamName | string | Current user's Steam name |
Methods
| Method | Returns | Description |
|---|---|---|
InitializeAsync(uint appId) | UniTask<bool> | Initialize Steam client |
GetSessionTicketAsync() | UniTask<byte[]> | Get a session ticket for auth |
Shutdown() | void | Shutdown Steam client |
Authentication Flow
┌─────────────────�? ┌─────────────────�? ┌─────────────────�?�? Steam Client �? �? Your Game �? �? PlayKit API �?└────────┬────────�? └────────┬────────�? └────────┬────────�? �? �? �? │◄─────── Initialize ────�? �? �? �? �? │─── Session Ticket ────►│ �? �? �? �? �? │─── Verify Ticket ─────►│
�? �? �? �? │◄── Player Token ───────�? �? �? �? �? �? Authenticated! �? �? �? �?```
## Example Implementation
```csharp
using UnityEngine;
using PlayKit_SDK;
using PlayKit_SDK.Steam;
using Cysharp.Threading.Tasks;
public class SteamLoginManager : MonoBehaviour
{
[SerializeField] private uint steamAppId = 480; // Replace with your App ID
private PlayKit_SteamAuthManager _steamAuth;
private void Awake()
{
_steamAuth = gameObject.AddComponent<PlayKit_SteamAuthManager>();
_steamAuth.SetSteamAppId(steamAppId);
}
private async void Start()
{
_steamAuth.OnAuthSuccess += HandleAuthSuccess;
_steamAuth.OnAuthError += HandleAuthError;
// Wait for Steam authentication
bool success = await _steamAuth.AuthenticateAsync();
if (success)
{
// Initialize PlayKit SDK with Steam token
await PlayKit_SDK.InitializeAsync();
LoadMainMenu();
}
}
private void HandleAuthSuccess(SteamAuthResult result)
{
Debug.Log($"Steam login successful!");
Debug.Log($"User ID: {result.userId}");
Debug.Log($"Steam ID: {result.steamId}");
Debug.Log($"Steam Name: {result.steamName}");
}
private void HandleAuthError(string error)
{
Debug.LogError($"Steam login failed: {error}");
ShowLoginErrorUI(error);
}
private void LoadMainMenu()
{
UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
}
private void ShowLoginErrorUI(string message)
{
// Show error dialog to user
}
}Troubleshooting
"Failed to initialize Steam"
- Make sure Steam is running
- Check that your Steam App ID is correct
- Verify you own the game on Steam (for testing)
"Steam ticket verification failed"
- Verify your Steam Web API Key is configured in PlayKit dashboard
- Check that the App ID matches your channel configuration
- Ensure the API key has access to the App ID
"Steamworks not found"
- Make sure Facepunch.Steamworks is included in the Steam Addon package
- Check that your Unity version is compatible (2020.3+)
- Verify the Steam Addon package is properly installed
Platform Notes
Windows
- Full support for Steam authentication
- Steam client must be running
macOS
- Supported with Steam client installed
Linux
- Supported with Steam client installed
Steam Deck
- Works out of the box when running through Steam
Best Practices
- Always handle auth errors: Provide fallback options if Steam auth fails
- Check Steam status: Verify Steam is running before attempting auth
- Secure your API key: Never expose your Steam Web API key in client code
- Test all channels: Verify auth works for release, demo, and playtest builds
- Handle offline mode: Gracefully handle when Steam is in offline mode
Next Steps
- Learn about Authentication for other auth methods
- Explore Payment for Steam-based purchases
- See Publishing for Steam release guidelines