Overview
Authentication in GlobalTV Roku is credential-based. The user enters a username and password on theLoginScreen, and AuthTask calls the backend to validate them. On success, credentials are saved to the Roku Registry and used for auto-login on the next launch. A background session check re-authenticates at a fixed interval while the app is running.
AuthTask
Background task that performs the HTTP auth request and writes result fields
RegistryManager
Persists and retrieves credentials under the
GlobalTV registry sectionLoginScreen
Captures username and password using Roku’s on-device keyboard dialog
GTV_AuthClassifyFailure
Classifies every auth failure into one of five reason codes
Auth flow
User enters credentials
LoginScreen opens a StandardKeyboardDialog for the username field, then another for the password field. On submit, it calls TryLogin(), which first requests the Roku email via ChannelStore.getUserData (RFI), then starts AuthTask.Server resolution
AuthTask calls GTV_ResolveServerForAuth(), which iterates the server probe list — LAN servers first, then the public WAN server — using health-check pings. The first server that responds becomes the active server for this session and is saved to the Registry (lastServer key).Auth HTTP request
AuthTask issues a GET to the auth endpoint with URL-encoded credentials:AppConstants.PATH_AUTH_TPL) is:Response parsing
On HTTP 2xx, the task parses the JSON body and checks the
subscriberStatus, subscriber_active, or active fields to confirm the subscriber is active. If any field signals an inactive account, the task classifies the failure and exits without saving credentials.Success: credentials saved
On a fully successful auth,
AuthTask saves credentials to the Registry and sets global state:Auth endpoint
The endpoint template is defined inAppConstants as PATH_AUTH_TPL:
AuthTask builds the URL by URL-encoding both values:
Auto-login
On every app launch,MainScene checks whether credentials exist in the Registry before showing the LoginScreen:
MainScene skips the LoginScreen and starts AuthTask directly with the saved values.
Registry keys
All registry values are stored under theGlobalTV section (REG_SECTION = "GlobalTV").
| Constant | Key string | Purpose |
|---|---|---|
REG_KEY_USER | username | Saved username |
REG_KEY_PASS | password | Saved password |
REG_KEY_SERVER | lastServer | Last resolved server URL |
REG_KEY_CHANNEL | lastChannelIndex | Last viewed channel index (for resume) |
Session re-auth check
After a successful launch,MainScene runs a periodic re-auth check to detect expired or revoked sessions while the app is in use.
LoginScreen with a pre-populated error notice.
Timeouts and retries
| Constant | Value | Description |
|---|---|---|
TIMEOUT_AUTH | 15000 ms | Maximum wait time for the auth HTTP response |
TIMEOUT_HTTP | 12000 ms | General HTTP timeout used for non-auth requests |
TIMEOUT_HEALTH | 2500 ms | Server ping timeout during server resolution |
RETRY_MAX | 3 | Maximum retry attempts for network-level failures |
SERVER_LAN_FORCE_RETRIES | 3 | Number of LAN probe retries before failing over to WAN |
LoginScreen also arms a guard timer to cancel a hung auth attempt. The guard duration is computed as:
Failure classification
GTV_AuthClassifyFailure maps every auth error to one of five integer reason codes. Both AuthTask and PlaylistTask call this function to decide how to present errors to the user and whether to clear credentials.
Reason codes
| Constant | Value | Meaning |
|---|---|---|
AUTH_REASON_NONE | 0 | No failure — auth succeeded |
AUTH_REASON_NETWORK_DOWN | 460 | Network unavailable or HTTP timeout (code = -1) |
AUTH_REASON_CREDENTIALS | 401 | Wrong username or password |
AUTH_REASON_INACTIVE | 470 | Account exists but subscriber is inactive |
AUTH_REASON_PASSWORD_CHANGED | 471 | Password was changed or session was revoked |
Function signature
httpCode— The HTTP response code.-1immediately returnsAUTH_REASON_NETWORK_DOWN.reasonText— A string hint from the response (e.g. thereasonormessagefield). May beinvalid.bodyText— The raw response body string or parsed object. The function extracts signal text from nested JSON keys (message,reason,error,detail,status,user_inactive_reason,subscriberDisabledReason).subscriberActive— Boolean hint from a parsed subscriber status field. If explicitlyfalse, returnsAUTH_REASON_INACTIVE.
Classification logic
Signal text is Unicode-normalized (accented characters stripped) and lowercased before pattern matching, so Spanish and English error messages from the backend are handled identically.
How LoginScreen reacts to each code
| Code | UI behavior |
|---|---|
AUTH_REASON_CREDENTIALS | Clears the password field, focuses password input, shows error message |
AUTH_REASON_PASSWORD_CHANGED | Clears the password field, focuses password input, shows error message |
AUTH_REASON_INACTIVE | Clears the password field, focuses the login button, shows error message |
AUTH_REASON_NETWORK_DOWN | Shows the server timeout error, focuses the login button |
AUTH_REASON_NONE (unexpected) | Shows generic error, focuses the login button |