Skip to main content

STXLoginService

public class STXLoginService
{
    Task<STXUserDataCollection> LoginAsync(
        string email,
        string password,
        bool checkTermsAndConditions = false,
        bool keepSessionAlive = false,
        string deviceId = STXDefaultSettings.DeviceId);
}

Args

email, passwordCredentials
checkTermsAndConditionsIf true, the SDK checks whether new T&Cs need acceptance and sets PromptTncAcceptance on the result
keepSessionAliveIf true, starts STXSessionBackgroundService which refreshes the token + periodically re-logins before the refresh window expires. Requires the SDK to be registered under a hosted IHost so background services run.
deviceIdClient-provided device identifier

STXUserDataCollection

Fields returned from login (and Confirm2FAAsync):
TokenJWT bearer for GraphQL
RefreshTokenUsed by RefreshTokenAsync
UserId, UserUidUser identifiers (UserId is used for channel topics)
SessionIdNeeded for Confirm2FAAsync when 2FA is enabled
CurrentLoginAtLogin timestamp
PromptTncAcceptancetrue if T&Cs need acceptance
PromptTwoFactortrue if 2FA completion is pending

Exceptions

STXWrongCredentialsExceptionBad email/password
STXGeoComplyExceptionGeo check failed

STXTokenService

public class STXTokenService
{
    Task<STXUserDataCollection> LoginAsync(
        string email,
        string password,
        bool keepSessionAlive,
        string deviceId = STXDefaultSettings.DeviceId);

    Task<STXUserDataCollection> Confirm2FAAsync(
        string code,
        string sessionId,
        string email);

    Task<STXUserDataCollection> RefreshTokenAsync();
}
STXLoginService.LoginAsync delegates to STXTokenService.LoginAsync under the hood — use the token service directly when you need to break apart the login + 2FA + T&C steps (e.g. a multi-step UI).

Exceptions from RefreshTokenAsync

  • STXSessionExpiredException — token AND refresh token both expired. Full re-login required.

STXSessionBackgroundService

Registered as a hosted background service. Kicks on when LoginAsync(keepSessionAlive: true) fires. Responsibilities:
  • Every ~15 min, check whether the JWT is within the expiry window; if yes, call RefreshTokenAsync.
  • If the refresh token itself is close to expiry, re-login using the password cached in STXUserStorage.
You never call this directly — just toggle keepSessionAlive. Task-oriented examples: Authentication.