PlayKit.ai

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)

  1. Open Window > Package Manager
  2. Click + > Add package from git URL
  3. 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

  1. Go to Tools > PlayKit SDK > Settings
  2. Enter your Game ID (from PlayKit dashboard)
  3. Make sure your game is configured as a Steam channel (steam_release, steam_demo, or steam_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

PropertyTypeDescription
IsAuthenticatedboolWhether the user is currently authenticated
SteamIdulongThe user's Steam ID (64-bit format)
SteamAppIduintThe Steam App ID being used
LastAuthResultSteamAuthResultThe last authentication result

Methods

MethodReturnsDescription
SetSteamAppId(uint appId)voidSet the Steam App ID at runtime
AuthenticateAsync()UniTask<bool>Initialize Steam and authenticate with PlayKit
Logout()voidClear authentication state

Events

EventDescription
OnAuthSuccessFired when authentication succeeds
OnAuthErrorFired when authentication fails

PlayKit_SteamService

Low-level Steamworks wrapper for advanced use cases.

Properties

PropertyTypeDescription
IsInitializedboolWhether Steam is initialized
SteamIdulongCurrent user's Steam ID
SteamNamestringCurrent user's Steam name

Methods

MethodReturnsDescription
InitializeAsync(uint appId)UniTask<bool>Initialize Steam client
GetSessionTicketAsync()UniTask<byte[]>Get a session ticket for auth
Shutdown()voidShutdown 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

  1. Always handle auth errors: Provide fallback options if Steam auth fails
  2. Check Steam status: Verify Steam is running before attempting auth
  3. Secure your API key: Never expose your Steam Web API key in client code
  4. Test all channels: Verify auth works for release, demo, and playtest builds
  5. Handle offline mode: Gracefully handle when Steam is in offline mode

Next Steps