GameService.Sdk.Auth 1.0.5

dotnet add package GameService.Sdk.Auth --version 1.0.5
                    
NuGet\Install-Package GameService.Sdk.Auth -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GameService.Sdk.Auth" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GameService.Sdk.Auth" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="GameService.Sdk.Auth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GameService.Sdk.Auth --version 1.0.5
                    
#r "nuget: GameService.Sdk.Auth, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GameService.Sdk.Auth@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GameService.Sdk.Auth&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=GameService.Sdk.Auth&version=1.0.5
                    
Install as a Cake Tool

GameService Auth SDK

The Auth SDK handles user authentication, session management, and basic player profile operations (balance, daily rewards). It is the entry point for any application connecting to the GameService.

Installation

Include GameService.Sdk.Auth.dll and its dependencies in your project.

Usage

1. Initialize the Client

using GameService.Sdk.Auth;

var authClient = new AuthClient("http://localhost:5525");

2. Login or Register

Guest Login

Quickly create a temporary account.

var result = await authClient.GuestLoginAsync();
if (result.Success)
{
    Console.WriteLine($"Logged in as guest!");
    var session = result.Session;
}
Email/Password Login
var result = await authClient.LoginAsync("user@example.com", "password123");
Register
var result = await authClient.RegisterAsync("user@example.com", "password123");
if (result.Success)
{
    // Now login
}

3. Managing the Session

The LoginResult returns a GameSession object which manages your access tokens and provides access to authenticated features.

var session = result.Session;

// Check balance
var balance = await session.GetBalanceAsync();

// Get Profile
var profile = await session.GetProfileAsync();
Console.WriteLine($"User: {profile.UserName}, Coins: {profile.Coins}");

// Claim Daily Rewards
var claim = await session.ClaimDailyLoginAsync();
if (claim.Success)
{
    Console.WriteLine($"Claimed {claim.Reward} coins!");
}

4. Connecting to Game Server

The session provides a helper to connect to the real-time game hub.

var gameClient = await session.ConnectToGameAsync();

5. Token Refresh

The GameSession automatically handles token expiration and refreshing when you use its methods or ConnectToGameAsync.


Get Started with Unity

The Auth SDK handles user authentication and profile management.

Key Classes

  • AuthClient: Authentication operations
  • GameSession: User session with token management
  • PlayerProfile: User profile data

Authentication Flow

using GameService.Sdk.Auth;

public class AuthManager : MonoBehaviour
{
    private AuthClient authClient;
    private GameSession session;
    
    private void Start()
    {
        authClient = new AuthClient("https://your-server.com");
    }
    
    // Guest login (no registration required)
    public async Task<bool> LoginAsGuest()
    {
        var result = await authClient.GuestLoginAsync();
        if (result.Success)
        {
            session = result.Session;
            Debug.Log("Guest login successful!");
            return true;
        }
        
        Debug.LogError($"Guest login failed: {result.Error}");
        return false;
    }
    
    // Email/password registration
    public async Task<bool> Register(string email, string password)
    {
        var result = await authClient.RegisterAsync(email, password);
        if (result.Success)
        {
            Debug.Log("Registration successful!");
            return await Login(email, password);
        }
        
        Debug.LogError($"Registration failed: {result.Error}");
        return false;
    }
    
    // Email/password login
    public async Task<bool> Login(string email, string password)
    {
        var result = await authClient.LoginAsync(email, password);
        if (result.Success)
        {
            session = result.Session;
            Debug.Log("Login successful!");
            return true;
        }
        
        Debug.LogError($"Login failed: {result.Error}");
        return false;
    }
    
    // Google OAuth login
    public async Task<bool> LoginWithGoogle(string idToken)
    {
        var result = await authClient.GoogleLoginAsync(idToken);
        if (result.Success)
        {
            session = result.Session;
            Debug.Log("Google login successful!");
            return true;
        }
        
        Debug.LogError($"Google login failed: {result.Error}");
        return false;
    }
}

Profile Management

// Get user profile
var profile = await session.GetProfileAsync();
if (profile != null)
{
    Debug.Log($"User: {profile.UserName}");
    Debug.Log($"Email: {profile.Email}");
    Debug.Log($"Coins: {profile.Coins}");
}

// Get coin balance
var balance = await session.GetBalanceAsync();
Debug.Log($"Balance: {balance} coins");

// Daily rewards
var loginReward = await session.ClaimDailyLoginAsync();
if (loginReward.Success)
{
    Debug.Log($"Daily login: +{loginReward.Reward} coins!");
    Debug.Log($"New balance: {loginReward.NewBalance}");
}

var spinReward = await session.ClaimDailySpinAsync();
if (spinReward.Success)
{
    Debug.Log($"Daily spin: +{spinReward.Reward} coins!");
}

// Transaction history
var history = await session.GetTransactionHistoryAsync(page: 1, pageSize: 20);
foreach (var transaction in history.Items)
{
    Debug.Log($"{transaction.CreatedAt}: {transaction.Amount} coins - {transaction.Description}");
}

Session to GameClient

// Connect to game hub using session
var gameClient = await session.ConnectToGameAsync();

// The session automatically handles token refresh
Debug.Log($"Connected with token: {session.AccessToken}");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on GameService.Sdk.Auth:

Package Downloads
Project01.Practice

A basic SignalR Chat Hub and client assets.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 98 2/16/2026
1.0.4 250 12/19/2025
1.0.3 262 12/19/2025
1.0.2 281 12/18/2025
1.0.1 274 12/18/2025
1.0.0 242 12/15/2025