Table of Contents

Class ServerAuthenticator

Namespace
Shard.Network.Auth
Assembly
Shard.Network.Auth.dll

Authenticates the server itself at startup and owns the server's game session ("slot"). In Offline it is a no-op. In Authenticated it obtains an access token (env or OAuth device flow), then acquires a game session. ReleaseAsync(CancellationToken) frees the slot on shutdown so it does not count against the account's session limit.

public sealed class ServerAuthenticator
Inheritance
ServerAuthenticator
Inherited Members

Constructors

ServerAuthenticator(ServiceHttpClient, AuthConfig, IShardLogger)

Authenticates the server itself at startup and owns the server's game session ("slot"). In Offline it is a no-op. In Authenticated it obtains an access token (env or OAuth device flow), then acquires a game session. ReleaseAsync(CancellationToken) frees the slot on shutdown so it does not count against the account's session limit.

public ServerAuthenticator(ServiceHttpClient http, AuthConfig config, IShardLogger log)

Parameters

http ServiceHttpClient
config AuthConfig
log IShardLogger

Properties

AccessToken

public string? AccessToken { get; }

Property Value

string

ServerIdentityToken

The server's identity token (sent to clients in AuthGrant); null until acquired.

public string? ServerIdentityToken { get; }

Property Value

string

ServerSessionId

Per-boot identifier used as the audience when requesting player auth grants.

public Guid ServerSessionId { get; }

Property Value

Guid

SessionToken

The server's game session token while a slot is held; null otherwise.

public string? SessionToken { get; }

Property Value

string

Methods

AuthenticateAsync(AuthMode, CancellationToken)

public Task AuthenticateAsync(AuthMode mode, CancellationToken ct = default)

Parameters

mode AuthMode
ct CancellationToken

Returns

Task

ReleaseAsync(CancellationToken)

Release the server's game session slot. Safe to call multiple times; never throws. The refreshed OAuth tokens (not the now-dead session) are persisted so the next start can refresh rather than re-run the device flow.

public Task ReleaseAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task