AuthTask runs RunAuth on a worker thread. It resolves the best available server (LAN first, then WAN), posts credentials to /auth/{user}/{pass}, parses the JSON response, and signals success or a typed failure reason via the result and done output fields.
AuthTask uses TIMEOUT_AUTH (15 000 ms) for the credential HTTP request — longer than the default TIMEOUT_HTTP — to allow for slow LAN servers.XML component definition
AuthTask.xml
Input fields
The subscriber’s username. Leading and trailing whitespace is stripped before use. An empty value causes an immediate failure with
errorMsg set.The subscriber’s password. Trimmed the same way as
username.Output fields
Populated when
done becomes true. Contains the fields listed in the Result object section below.Set to
true once the task finishes, whether successful or not. Observe this field to know when result is ready.Human-readable progress string updated throughout the task (e.g.
"Conectando con servidor local...", "Validando credenciales..."). Suitable for display in the login screen.Monotonically incremented every time
statusMessage changes. Observe this integer field to detect message updates even when the string value is identical.Result object
Theresult assoc-array always contains these keys:
| Key | Type | Description |
|---|---|---|
success | Boolean | true when the user authenticated and the subscription is active |
userId | String | Subscriber user ID returned by the server, or "" |
streamUrl | String | Reserved; currently always "" |
subscriberActive | Boolean | true when the subscription is in good standing |
subscriberDisabledReason | String | Human-readable reason from the server when the account is inactive |
errorCode | Integer | One of the AUTH_REASON_* constants (see Error codes) |
authReason | Integer | Alias for errorCode; same value |
errorMsg | String | Localised error string suitable for display |
rawBody | String | Raw HTTP response body, useful for debugging |
resolvedServer | String | Base URL of the server that answered the request |
Error codes
Defined inAppConstants.brs:
| Constant | Value | Meaning |
|---|---|---|
AUTH_REASON_NONE | 0 | No error; authentication succeeded |
AUTH_REASON_NETWORK_DOWN | 460 | Network unavailable or all servers timed out |
AUTH_REASON_CREDENTIALS | 401 | Wrong username or password |
AUTH_REASON_INACTIVE | 470 | Account exists but subscription is inactive |
AUTH_REASON_PASSWORD_CHANGED | 471 | Session revoked because credentials were rotated |
Function flow
Validate inputs
GTV_SafeTrim strips whitespace from username and password. If either is empty the task sets done = true immediately with an error result.Check network
GTV_IsOnline() confirms a network interface is up. Failure sets errorCode = AUTH_REASON_NETWORK_DOWN.Resolve server
GTV_ResolveServerForAuth() iterates GTV_ServerBuildAutoProbeList() — LAN entries first, then WAN — pinging each with GTV_PingServer(). The first reachable server is used. statusMessage is updated at each probe step.POST credentials
Builds
server + "/auth/" + encUser + "/" + encPass and calls GTV_HttpGet(authUrl, TIMEOUT_AUTH). The 15 s timeout gives LAN servers extra time to respond.Classify HTTP failure
If the HTTP call fails,
GTV_AuthClassifyFailure() maps the HTTP code and body to an AUTH_REASON_* constant and an appropriate errorMsg.Parse subscriber status
Inspects
subscriberStatus, subscriber_active, and active fields (in that order) to determine whether the account is enabled. A false value triggers a failure path that emits AUTH_REASON_INACTIVE or AUTH_REASON_PASSWORD_CHANGED.Write global state
On success: sets
m.global.activeServer, m.global.isAuthenticated = true, m.global.subscriberActive = true, and m.global.userId. Saves the resolved server via GTV_RegSaveLastServer().AppConstants values used
| Constant | Value | Used for |
|---|---|---|
TIMEOUT_AUTH | 15000 ms | HTTP timeout for the credential request |
TIMEOUT_HEALTH | 2500 ms | Ping timeout inside GTV_PingServer() |
SERVER_LAN_FORCE_RETRIES | 3 | Maximum LAN probe attempts before falling back to WAN |
PATH_AUTH_TPL | "/auth/{user}/{pass}" | URL template for the auth endpoint |
AUTH_REASON_* | see table above | Typed failure codes written to result.errorCode |