LoginAsync once and forget about it.
Simple login
LoginAsync returns STXUserDataCollection with:
| Field | |
|---|---|
Token | Bearer token for subsequent GraphQL calls |
RefreshToken | Used by STXTokenService.RefreshTokenAsync |
UserId, UserUid, SessionId | Identifiers for channel subscriptions |
CurrentLoginAt | Login timestamp |
PromptTncAcceptance | true if the user still needs to accept new T&Cs |
STXUserStorage and attached to every subsequent GraphQL call. You never need to pass it manually.
Two-factor authentication
If the account has 2FA enabled, the initialLoginAsync returns partial user data — authentication isn’t complete until you confirm the code:
confirm2Fa mutation the Python SDK and other clients use.
Keep the session alive
Long-running bots should refresh the token before it expires. PasskeepSessionAlive: true and the SDK’s STXSessionBackgroundService will refresh in the background:
- The service provider must be hosted under
Host.CreateDefaultBuilder(...)so background services actually run. - The credentials stay in memory in
STXUserStorageso the background service can re-login if the refresh token itself expires.
Accept terms & conditions
IfPromptTncAcceptance is true, subsequent authenticated calls will fail until the user accepts. Pass checkTermsAndConditions: true to have the SDK surface the latest T&Cs for your app to display:
Logout
No server-side logout call is required — just drop the token:Errors
| Exception | Cause |
|---|---|
STXWrongCredentialsException | Bad email/password |
STXSessionExpiredException | Token and refresh token both expired — re-login |
STXGeoComplyException | Geo-compliance check failed; user is outside a permitted jurisdiction |

